ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:109162] [Ruby master Bug#18902] Thread#value crash if the thread was killed because of a fork
@ 2022-07-07 14:22 byroot (Jean Boussier)
  2022-09-25  4:43 ` [ruby-core:110058] " nagachika (Tomoyuki Chikanaga)
  0 siblings, 1 reply; 2+ messages in thread
From: byroot (Jean Boussier) @ 2022-07-07 14:22 UTC (permalink / raw)
  To: ruby-core

Issue #18902 has been reported by byroot (Jean Boussier).

----------------------------------------
Bug #18902: Thread#value crash if the thread was killed because of a fork
https://bugs.ruby-lang.org/issues/18902

* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.2.0dev, ruby 3.1.2p20, ruby 3.0.3p157, ruby 2.7.5p203 
* Backport: 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED
----------------------------------------
Reproduction script 

```ruby
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.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [ruby-core:110058] [Ruby master Bug#18902] Thread#value crash if the thread was killed because of a fork
  2022-07-07 14:22 [ruby-core:109162] [Ruby master Bug#18902] Thread#value crash if the thread was killed because of a fork byroot (Jean Boussier)
@ 2022-09-25  4:43 ` nagachika (Tomoyuki Chikanaga)
  0 siblings, 0 replies; 2+ messages in thread
From: nagachika (Tomoyuki Chikanaga) @ 2022-09-25  4:43 UTC (permalink / raw)
  To: ruby-core

Issue #18902 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED to 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE

ruby_3_1 720de2008ca06edb22e5ad7d1432fee4f2575e00 merged revision(s) 65ae2bb2e045aa8b668d3c30515f5a6cb3eb68ad.

----------------------------------------
Bug #18902: Thread#value crash if the thread was killed because of a fork
https://bugs.ruby-lang.org/issues/18902#change-99309

* Author: byroot (Jean Boussier)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.2.0dev, ruby 3.1.2p20, ruby 3.0.3p157, ruby 2.7.5p203 
* Backport: 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE
----------------------------------------
Reproduction script 

```ruby
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.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-25  4:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 14:22 [ruby-core:109162] [Ruby master Bug#18902] Thread#value crash if the thread was killed because of a fork byroot (Jean Boussier)
2022-09-25  4:43 ` [ruby-core:110058] " nagachika (Tomoyuki Chikanaga)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).