diff options
author | nagachika <nagachika@ruby-lang.org> | 2022-09-25 12:33:30 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2022-09-25 12:33:30 +0900 |
commit | 720de2008ca06edb22e5ad7d1432fee4f2575e00 (patch) | |
tree | 8eff85a76e26b77bb2afe07a3f28693eeeb2a6a4 /test | |
parent | 2fb900e6a0cc5625b95495eed8890cd58c94e66f (diff) |
merge revision(s) 65ae2bb2e045aa8b668d3c30515f5a6cb3eb68ad: [Backport #18902]
Thread#value: handle threads killed by a fork
[Bug #18902]
When a thread is killed because we forked, the `value` if left
to `Qundef`. Returning it woudl crash the VM.
---
test/ruby/test_thread.rb | 14 ++++++++++++++
thread.c | 4 ++++
2 files changed, 18 insertions(+)
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_thread.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index ddfeb8b7a8..41cee124be 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -1244,6 +1244,20 @@ q.pop assert_predicate(status, :success?, bug9751) end if Process.respond_to?(:fork) + def test_fork_value + bug18902 = "[Bug #18902]" + th = Thread.start { sleep 2 } + begin + pid = fork do + th.value + end + _, status = Process.wait2(pid) + assert_predicate(status, :success?, bug18902) + ensure + th.kill + end + end if Process.respond_to?(:fork) + def test_fork_while_locked m = Thread::Mutex.new thrs = [] |