diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2022-07-07 16:28:43 +0200 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2022-07-07 19:49:25 +0200 |
commit | 65ae2bb2e045aa8b668d3c30515f5a6cb3eb68ad (patch) | |
tree | 4222033703f5e7bf7ed1457ceb099510fdbbffd8 /test/ruby/test_thread.rb | |
parent | 7dd0a2258880e433b98267ffd95dd4271c7bbf05 (diff) |
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.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6103
Diffstat (limited to 'test/ruby/test_thread.rb')
-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 cdb7309fb7..a018f3cdac 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -1249,6 +1249,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 = [] |