From 31c0e3385f6b46390b4a44618d443819550467b7 Mon Sep 17 00:00:00 2001 From: mame Date: Sun, 15 Nov 2009 15:10:49 +0000 Subject: * thread.c (thread_cleanup_func): delete locking_mutex when thread object become dummy because of fork. [ruby-core:26744] [ruby-core:26745] * bootstraptest/test_thread.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ bootstraptest/test_thread.rb | 23 +++++++++++++++++++++++ thread.c | 1 + 3 files changed, 32 insertions(+) diff --git a/ChangeLog b/ChangeLog index d3261cd6fa..1aae8e1847 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Nov 16 00:06:26 2009 Yusuke Endoh + + * thread.c (thread_cleanup_func): delete locking_mutex when thread + object become dummy because of fork. [ruby-core:26744] + [ruby-core:26745] + + * bootstraptest/test_thread.rb: add a test for above. + Sat Nov 14 21:54:46 2009 Yusuke Endoh * class.c (rb_mod_init_copy): fix memory leak of Class#dup. diff --git a/bootstraptest/test_thread.rb b/bootstraptest/test_thread.rb index 0e7d03d436..4b715a1545 100644 --- a/bootstraptest/test_thread.rb +++ b/bootstraptest/test_thread.rb @@ -385,3 +385,26 @@ assert_equal 'ok', %q{ end :ok } + +assert_equal 'ok', %{ + open("zzz.rb", "w") do |f| + f.puts <<-END + begin + m = Mutex.new + Thread.new { m.lock; sleep 1 } + sleep 0.3 + Thread.new do + sleep 0.3 + fork { GC.start } + end + m.lock + pid, status = Process.wait2 + $result = status.success? ? :ok : :ng + rescue NotImplementedError + $result = :ok + end + END + end + require "./zzz.rb" + $result +} diff --git a/thread.c b/thread.c index ba717bd2a8..5ea1982378 100644 --- a/thread.c +++ b/thread.c @@ -380,6 +380,7 @@ thread_cleanup_func(void *th_ptr) rb_mutex_unlock_all(th->keeping_mutexes, th); th->keeping_mutexes = NULL; } + th->locking_mutex = Qfalse; thread_cleanup_func_before_exec(th_ptr); native_thread_destroy(th); } -- cgit v1.2.3