From 0bdfc7243fe2d815aff62f4467663c52062cfbf2 Mon Sep 17 00:00:00 2001 From: nagachika Date: Wed, 19 Feb 2014 16:28:06 +0000 Subject: merge revision(s) r43148,r43149,r43152: [Backport #8433] * 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/branches/ruby_2_0_0@45049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_thread.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test') diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index 4aed34d5ba..9ac2c30710 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -937,4 +937,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 if Process.respond_to?(:fork) end -- cgit v1.2.3