Project

General

Profile

Actions

Bug #18902

closed

Thread#value crash if the thread was killed because of a fork

Added by byroot (Jean Boussier) about 1 month ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.0dev, ruby 3.1.2p20, ruby 3.0.3p157, ruby 2.7.5p203
[ruby-core:109162]

Description

Reproduction script

thr = Thread.new { sleep 10} 
fork do
  p thr.status # =>false
  p thr.join # => #<Thread:0x00000001008ae480 /tmp/thread-join.rb:1 dead>
  p thr.value # Assertion Failed: ./vm_core.h:1303:VM_ENV_FLAGS:FIXNUM_P(flags) (or crash if RUBY_DEBUG isn't set)
end

What happens is that rb_thread_t->value is initialized to Qundef, so when the thread is killed by a fork, Thread#value tries to return Qundef which laters crash the VM.

I have a patch incomming.

Actions #1

Updated by byroot (Jean Boussier) about 1 month ago

  • Status changed from Open to Closed

Applied in changeset git|65ae2bb2e045aa8b668d3c30515f5a6cb3eb68ad.


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.

Actions

Also available in: Atom PDF