summaryrefslogtreecommitdiff
path: root/libguile
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-12-01 12:57:49 +0100
committerAndy Wingo <wingo@pobox.com>2011-12-01 12:57:49 +0100
commit738c899e4c1ab9d25cfbcd1010f34e0cce400bca (patch)
tree1b89940ede7391cefbe8624ef502570b4540ffb2 /libguile
parentfd51e66190bde8cef74fec9725de4da3471901c4 (diff)
downloadguile-738c899e4c1ab9d25cfbcd1010f34e0cce400bca.tar.gz
fix deadlock in before-gc-hook on certain 7.2alpha gc versions
* libguile/gc.c (scm_init_gc): Only adjust gc frequency in the gc start hook if we know that it won't take a lock.
Diffstat (limited to 'libguile')
-rw-r--r--libguile/gc.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libguile/gc.c b/libguile/gc.c
index c03c23982..ff1ebe6b1 100644
--- a/libguile/gc.c
+++ b/libguile/gc.c
@@ -1024,11 +1024,20 @@ scm_init_gc ()
after_gc_async_thunk),
SCM_BOOL_F);
- scm_c_hook_add (&scm_before_gc_c_hook, adjust_gc_frequency, NULL, 0);
scm_c_hook_add (&scm_before_gc_c_hook, queue_after_gc_hook, NULL, 0);
scm_c_hook_add (&scm_before_gc_c_hook, start_gc_timer, NULL, 0);
scm_c_hook_add (&scm_after_gc_c_hook, accumulate_gc_timer, NULL, 0);
+#if HAVE_GC_GET_HEAP_USAGE_SAFE
+ /* GC_get_heap_usage does not take a lock, and so can run in the GC
+ start hook. */
+ scm_c_hook_add (&scm_before_gc_c_hook, adjust_gc_frequency, NULL, 0);
+#else
+ /* GC_get_heap_usage might take a lock (and did from 7.2alpha1 to
+ 7.2alpha7), so call it in the after_gc_hook. */
+ scm_c_hook_add (&scm_after_gc_c_hook, adjust_gc_frequency, NULL, 0);
+#endif
+
#ifdef HAVE_GC_SET_START_CALLBACK
GC_set_start_callback (run_before_gc_c_hook);
#endif