From: "byroot (Jean Boussier) via ruby-core" Date: 2026-03-04T21:55:55+00:00 Subject: [ruby-core:124921] [Ruby Bug#21941] Local variable becomes nil when YJIT enabled mid-method with fork/signal/ensure Issue #21941 has been updated by byroot (Jean Boussier). Assignee set to jit Backport changed from 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.2: DONTNEED, 3.3: DONTNEED, 3.4: REQUIRED, 4.0: REQUIRED Reduced even further: ```ruby def run fork_safe = ->(t) { t } RubyVM::YJIT.enable read, wakeup = IO.pipe wakeup.write("!") begin while true begin next if read.wait_readable rescue Interrupt end end ensure end end run ``` ---------------------------------------- Bug #21941: Local variable becomes nil when YJIT enabled mid-method with fork/signal/ensure https://bugs.ruby-lang.org/issues/21941#change-116580 * Author: nicholasdower (Nick Dower) * Status: Open * Assignee: jit * ruby -v: ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [arm64-darwin25] * Backport: 3.2: DONTNEED, 3.3: DONTNEED, 3.4: REQUIRED, 4.0: REQUIRED ---------------------------------------- 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 '
' ``` See also: https://github.com/puma/puma/issues/3620 https://github.com/Shopify/ruby/issues/625 -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/