From cf606aeb06898a190a219f51b2a627eddc8f0a70 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 21 Jan 2011 23:33:52 +0000 Subject: Avoid deadlock when finalizer lock is held during gc. From-SVN: r169112 --- libgo/runtime/go-go.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libgo/runtime/go-go.c') diff --git a/libgo/runtime/go-go.c b/libgo/runtime/go-go.c index 112d52f..7c5f40d 100644 --- a/libgo/runtime/go-go.c +++ b/libgo/runtime/go-go.c @@ -315,6 +315,15 @@ gc_stop_handler (int sig __attribute__ ((unused))) return; } + if (__sync_bool_compare_and_swap (&pm->holds_finlock, 1, 1)) + { + /* Similarly, we can't interrupt the thread while it holds the + finalizer lock. Otherwise we can get into a deadlock when + mark calls runtime_walkfintab. */ + __sync_bool_compare_and_swap (&pm->gcing_for_finlock, 0, 1); + return; + } + stop_for_gc (); } -- cgit v1.1