summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2022-09-25 12:33:30 +0900
committernagachika <nagachika@ruby-lang.org>2022-09-25 12:33:30 +0900
commit720de2008ca06edb22e5ad7d1432fee4f2575e00 (patch)
tree8eff85a76e26b77bb2afe07a3f28693eeeb2a6a4 /thread.c
parent2fb900e6a0cc5625b95495eed8890cd58c94e66f (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 'thread.c')
-rw-r--r--thread.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index 9476a7986a..de29340713 100644
--- a/thread.c
+++ b/thread.c
@@ -1364,6 +1364,10 @@ thread_value(VALUE self)
{
rb_thread_t *th = rb_thread_ptr(self);
thread_join(th, Qnil, 0);
+ if (th->value == Qundef) {
+ // If the thread is dead because we forked th->value is still Qundef.
+ return Qnil;
+ }
return th->value;
}