From: "rwstauner (Randy Stauner) via ruby-core" Date: 2026-10-07T21:30:18+00:00 Subject: [ruby-core:126995] [Ruby Bug#22415] Thread.handle_interrupt needs to preserve errinfo Issue #22415 has been updated by rwstauner (Randy Stauner). 4.0 backport PR: https://github.com/ruby/ruby/pull/19261 ---------------------------------------- Bug #22415: Thread.handle_interrupt needs to preserve errinfo https://bugs.ruby-lang.org/issues/22415#change-119387 * Author: rwstauner (Randy Stauner) * Status: Open * Backport: 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED ---------------------------------------- Thread.handle_interrupt checks for interrupts after its block has returned but before re-raising the break/return that left the block. A signal trap that runs in that window clears ec->errinfo, which is where the throw data for the pending break/return lives, so the VM throws nil. This small script reproduces the SEGV very quickly: ```ruby trap(:USR1) { raise "boom" rescue nil } pid = $$ killer = fork { (Process.kill(:USR1, pid); sleep 0.001) while Process.ppid == pid } 1_000_000.times { Thread.handle_interrupt(Exception => :immediate) { break } } Process.kill(:KILL, killer) puts "no crash" ``` -- 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/