summaryrefslogtreecommitdiff
path: root/libguile/threads.h
diff options
context:
space:
mode:
authorNeil Jerram <neil@ossau.uklinux.net>2009-01-15 22:36:28 +0000
committerNeil Jerram <neil@ossau.uklinux.net>2009-01-15 23:06:32 +0000
commit8b0174c879bf74981efe702a00471ed5b8e6912e (patch)
tree4916454c49bf51ca098d4f1e1d7d4c8f4a95e43e /libguile/threads.h
parent9ffef3c6f621bd4de70a0eb0dae4bb96c6026a79 (diff)
downloadguile-8b0174c879bf74981efe702a00471ed5b8e6912e.tar.gz
Don't try to unlock already unlocked heap mutex
For each thread that goes into Guile mode, Guile pushes a cleanup function, scm_leave_guile_cleanup, whose purpose is to execute `scm_leave_guile ()' if the thread is terminated while in Guile mode. The problem is that there are various places - like scm_pthread_cond_wait, scm_without_guile and scm_std_select - where the thread temporarily leaves Guile mode (which means unlocking the heap mutex), and the cleanup function is still in place. Therefore if the thread is terminated at these places, the cleanup function ends up trying to unlock a mutex (the heap mutex) which isn't actually locked. * libguile/threads.h (scm_i_thread): New heap_mutex_locked_by_self field. * libguile/threads.c (scm_enter_guile): Set heap_mutex_locked_by_self. (scm_leave_guile): Only unlock if heap_mutex_locked_by_self is 1. (guilify_self_1): Initialize heap_mutex_locked_by_self. (scm_i_thread_sleep_for_gc): Remove incorrect use of t->held_mutex here.
Diffstat (limited to 'libguile/threads.h')
-rw-r--r--libguile/threads.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/libguile/threads.h b/libguile/threads.h
index cbff64879..66ddb6aba 100644
--- a/libguile/threads.h
+++ b/libguile/threads.h
@@ -72,6 +72,13 @@ typedef struct scm_i_thread {
*/
scm_i_pthread_mutex_t heap_mutex;
+ /* Boolean tracking whether the above mutex is currently locked by
+ this thread. This is equivalent to whether or not the thread is
+ in "Guile mode". This field doesn't need any protection because
+ it is only ever set or tested by the owning thread.
+ */
+ int heap_mutex_locked_by_self;
+
/* The freelists of this thread. Each thread has its own lists so
that they can all allocate concurrently.
*/