guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, master, updated. release_1-9-3-45-g87f


From: Neil Jerram
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-3-45-g87f30ed
Date: Wed, 30 Sep 2009 21:00:48 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=87f30eda98b9c84807d54af6c76b6195c5cbd009

The branch, master has been updated
       via  87f30eda98b9c84807d54af6c76b6195c5cbd009 (commit)
       via  09d978f3f81d7ae43ba952de8dc568f54f5f80b6 (commit)
      from  43b03fbbdc8d3eddc04daa1a14c5e2eae3ee5a1f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 87f30eda98b9c84807d54af6c76b6195c5cbd009
Author: Neil Jerram <address@hidden>
Date:   Tue Mar 10 23:55:31 2009 +0000

    Fix spurious `throw from within critical section' errors
    
    The crux of this problem was that the thread doing a throw, and so
    checking scm_i_critical_section_level, was different from the thread
    that was in a critical section.
    
    * libguile/async.h (scm_i_critical_section_level): Removed, replaced
      by per-thread critical_section_level.
      (SCM_CRITICAL_SECTION_START, SCM_CRITICAL_SECTION_END): Use
      per-thread critical_section_level.
    
    * libguile/continuations.c (scm_dynthrow): Check per-thread
      critical_section_level.
    
    * libguile/threads.c (guilify_self_1): Init per-thread
      critical_section_level.
      (scm_i_critical_section_level): Removed.
    
    * libguile/threads.h (scm_i_thread): New critical_section_level field.
    
    * libguile/throw.c (scm_ithrow): Check per-thread critical_section_level.

commit 09d978f3f81d7ae43ba952de8dc568f54f5f80b6
Author: Neil Jerram <address@hidden>
Date:   Thu Mar 5 20:03:33 2009 +0000

    Avoid throw from critical section, given invalid sigaction call
    
    * libguile/scmsigs.c (scm_sigaction_for_thread): Exit critical section
      before raising out-of-range error.
    
    * test-suite/Makefile.am (SCM_TESTS): Add signals.test.
    
    * test-suite/tests/signals.test: New file.

-----------------------------------------------------------------------

Summary of changes:
 libguile/async.h              |    8 +++-----
 libguile/continuations.c      |    2 +-
 libguile/scmsigs.c            |    5 ++++-
 libguile/threads.c            |    2 +-
 libguile/threads.h            |    3 +++
 libguile/throw.c              |    2 +-
 test-suite/Makefile.am        |    1 +
 test-suite/tests/signals.test |   29 +++++++++++++++++++++++++++++
 8 files changed, 43 insertions(+), 9 deletions(-)
 create mode 100644 test-suite/tests/signals.test

diff --git a/libguile/async.h b/libguile/async.h
index 427d9b4..b9b795f 100644
--- a/libguile/async.h
+++ b/libguile/async.h
@@ -60,20 +60,18 @@ void scm_dynwind_unblock_asyncs (void);
    the manual.
 */
 
-/* Defined in threads.c.  scm_i_critical_section_level is only used
-   for error checking and will go away eventually. */
+/* Defined in threads.c. */
 extern scm_i_pthread_mutex_t scm_i_critical_section_mutex;
-extern int scm_i_critical_section_level;
 
 #define SCM_CRITICAL_SECTION_START \
   do { \
     scm_i_pthread_mutex_lock (&scm_i_critical_section_mutex);\
     SCM_I_CURRENT_THREAD->block_asyncs++; \
-    scm_i_critical_section_level++; \
+    SCM_I_CURRENT_THREAD->critical_section_level++; \
   } while (0)
 #define SCM_CRITICAL_SECTION_END \
   do { \
-    scm_i_critical_section_level--; \
+    SCM_I_CURRENT_THREAD->critical_section_level--; \
     SCM_I_CURRENT_THREAD->block_asyncs--; \
     scm_i_pthread_mutex_unlock (&scm_i_critical_section_mutex); \
     scm_async_click ();        \
diff --git a/libguile/continuations.c b/libguile/continuations.c
index aa1fb33..a0e2f6d 100644
--- a/libguile/continuations.c
+++ b/libguile/continuations.c
@@ -225,7 +225,7 @@ scm_dynthrow (SCM cont, SCM val)
   SCM_STACKITEM *dst = thread->continuation_base;
   SCM_STACKITEM stack_top_element;
 
-  if (scm_i_critical_section_level)
+  if (thread->critical_section_level)
     {
       fprintf (stderr, "continuation invoked from within critical section.\n");
       abort ();
diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c
index d9b36c5..f38d15c 100644
--- a/libguile/scmsigs.c
+++ b/libguile/scmsigs.c
@@ -340,7 +340,10 @@ SCM_DEFINE (scm_sigaction_for_thread, "sigaction", 1, 3, 0,
          install_handler (csig, SCM_BOOL_F, SCM_BOOL_F);
        }
       else
-       SCM_OUT_OF_RANGE (2, handler);
+       {
+         SCM_CRITICAL_SECTION_END;
+         SCM_OUT_OF_RANGE (2, handler);
+       }
     }
   else if (scm_is_false (handler))
     {
diff --git a/libguile/threads.c b/libguile/threads.c
index 8dce604..901695c 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -318,6 +318,7 @@ guilify_self_1 (SCM_STACKITEM *base)
   t->active_asyncs = SCM_EOL;
   t->block_asyncs = 1;
   t->pending_asyncs = 1;
+  t->critical_section_level = 0;
   t->last_debug_frame = NULL;
   t->base = base;
 #ifdef __ia64__
@@ -1855,7 +1856,6 @@ static int threads_initialized_p = 0;
 /* This mutex is used by SCM_CRITICAL_SECTION_START/END.
  */
 scm_i_pthread_mutex_t scm_i_critical_section_mutex;
-int scm_i_critical_section_level = 0;
 
 static SCM dynwind_critical_section_mutex;
 
diff --git a/libguile/threads.h b/libguile/threads.h
index 55102df..842f0d9 100644
--- a/libguile/threads.h
+++ b/libguile/threads.h
@@ -117,6 +117,9 @@ typedef struct scm_i_thread {
   scm_t_contregs *pending_rbs_continuation;
 #endif
 
+  /* Whether this thread is in a critical section. */
+  int critical_section_level;
+
 } scm_i_thread;
 
 #define SCM_I_IS_THREAD(x)    SCM_SMOB_PREDICATE (scm_tc16_thread, x)
diff --git a/libguile/throw.c b/libguile/throw.c
index cf6ea4a..07d215f 100644
--- a/libguile/throw.c
+++ b/libguile/throw.c
@@ -732,7 +732,7 @@ scm_ithrow (SCM key, SCM args, int noreturn SCM_UNUSED)
   SCM dynpair = SCM_UNDEFINED;
   SCM winds;
 
-  if (scm_i_critical_section_level)
+  if (SCM_I_CURRENT_THREAD->critical_section_level)
     {
       SCM s = args;
       int i = 0;
diff --git a/test-suite/Makefile.am b/test-suite/Makefile.am
index 476d6e6..f47ccba 100644
--- a/test-suite/Makefile.am
+++ b/test-suite/Makefile.am
@@ -67,6 +67,7 @@ SCM_TESTS = tests/alist.test                  \
            tests/reader.test                   \
            tests/receive.test                  \
            tests/regexp.test                   \
+           tests/signals.test                  \
            tests/socket.test                   \
            tests/srcprop.test                  \
            tests/srfi-1.test                   \
diff --git a/test-suite/tests/signals.test b/test-suite/tests/signals.test
new file mode 100644
index 0000000..7cab85e
--- /dev/null
+++ b/test-suite/tests/signals.test
@@ -0,0 +1,29 @@
+;;;; signals.test --- test suite for Guile's signal functions       -*- scheme 
-*-
+;;;; 
+;;;; Copyright (C) 2009 Free Software Foundation, Inc.
+;;;; 
+;;;; This program is free software; you can redistribute it and/or modify
+;;;; it under the terms of the GNU General Public License as published by
+;;;; the Free Software Foundation; either version 2, or (at your option)
+;;;; any later version.
+;;;; 
+;;;; This program is distributed in the hope that it will be useful,
+;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;;; GNU General Public License for more details.
+;;;; 
+;;;; You should have received a copy of the GNU General Public License
+;;;; along with this software; see the file COPYING.  If not, write to
+;;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;;;; Boston, MA 02110-1301 USA
+
+
+(use-modules (test-suite lib))
+
+(with-test-prefix "sigaction"
+
+  (pass-if-exception "handler arg is an invalid integer"
+    exception:out-of-range
+    (sigaction SIGINT 51))
+
+  )


hooks/post-receive
-- 
GNU Guile




reply via email to

[Prev in Thread] Current Thread [Next in Thread]