diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-01-21 23:33:52 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-01-21 23:33:52 +0000 |
commit | cf606aeb06898a190a219f51b2a627eddc8f0a70 (patch) | |
tree | e329a7851e062128fbf36f866fbdbcf94c2831cc /libgo/runtime/go-go.c | |
parent | 723553bdc16695ecc686a2ffdff6d15bd600b676 (diff) | |
download | gcc-cf606aeb06898a190a219f51b2a627eddc8f0a70.zip gcc-cf606aeb06898a190a219f51b2a627eddc8f0a70.tar.gz gcc-cf606aeb06898a190a219f51b2a627eddc8f0a70.tar.bz2 |
Avoid deadlock when finalizer lock is held during gc.
From-SVN: r169112
Diffstat (limited to 'libgo/runtime/go-go.c')
-rw-r--r-- | libgo/runtime/go-go.c | 9 |
1 files changed, 9 insertions, 0 deletions
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 (); } |