diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-05 02:21:12 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-05 02:21:12 +0000 |
commit | 57b8687debea4e532898cdf0380d63bb62749b9a (patch) | |
tree | 748f2ba1d9f13dbbda58037652357afa4e1dc89f /test | |
parent | a10c9a0e7660cfe9022a3ee74d048355518426f7 (diff) | |
download | ruby-57b8687debea4e532898cdf0380d63bb62749b9a.tar.gz |
thread.c: fix some mutexes remaining locked after forking
* thread.c (terminate_atfork_i): fix locking mutexes not unlocked in
forks when not tracked in thread. [ruby-core:55102] [Bug #8433]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_thread.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index bc3c025253..6d4237d7ff 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -909,4 +909,31 @@ Thread.new(Thread.current) {|mth| size_large = invoke_rec script, vm_stack_size, 1024 * 1024 * 10 assert_operator(size_default, :<=, size_large, "large size") end + + def test_blocking_mutex_unlocked_on_fork + bug8433 = '[ruby-core:55102] [Bug #8433]' + + mutex = Mutex.new + flag = false + mutex.lock + + th = Thread.new do + mutex.synchronize do + flag = true + sleep + end + end + + Thread.pass until th.stop? + mutex.unlock + + pid = Process.fork do + exit(mutex.locked?) + end + + th.kill + + pid, status = Process.waitpid2(pid) + assert_equal(false, status.success?, bug8433) + end end |