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 /thread.c | |
parent | 7dd0a2258880e433b98267ffd95dd4271c7bbf05 (diff) | |
download | ruby-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.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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; } |