Actions
Bug #21941
openLocal variable becomes nil when YJIT enabled mid-method with fork/signal/ensure
Bug #21941:
Local variable becomes nil when YJIT enabled mid-method with fork/signal/ensure
Description
The following code results in the read local variable becoming nil, even though it is never reassigned:
def run
fork_safe = ->(t) { t }
RubyVM::YJIT.enable
read, wakeup = IO.pipe
Signal.trap("SIGCHLD") { wakeup.write("!") }
begin
while true
begin
fork { exit }
next if read.wait_readable
rescue Interrupt
end
end
ensure
end
end
run
Error:
repro.rb:13:in 'Object#run': undefined method 'wait_readable' for nil (NoMethodError)
next if read.wait_readable
^^^^^^^^^^^^^^
from repro.rb:21:in '<main>'
See also:
https://github.com/puma/puma/issues/3620
https://github.com/Shopify/ruby/issues/625
Actions