summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2022-07-07 16:28:43 +0200
committerJean Boussier <jean.boussier@gmail.com>2022-07-07 19:49:25 +0200
commit65ae2bb2e045aa8b668d3c30515f5a6cb3eb68ad (patch)
tree4222033703f5e7bf7ed1457ceb099510fdbbffd8 /thread.c
parent7dd0a2258880e433b98267ffd95dd4271c7bbf05 (diff)
downloadruby-65ae2bb2e045aa8b668d3c30515f5a6cb3eb68ad.tar.gz
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.
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 620a56d9a0..5fd7a7f67a 100644
--- a/thread.c
+++ b/thread.c
@@ -1214,6 +1214,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;
}