From: "tenderlovemaking (Aaron Patterson) via ruby-core" Date: 2026-11-12T00:55:45+00:00 Subject: [ruby-core:127426] [Ruby Bug#22415] Thread.handle_interrupt needs to preserve errinfo Issue #22415 has been updated by tenderlovemaking (Aaron Patterson). Backport changed from 3.3: REQUIRED, 3.4: DONE, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ruby_4_0 commit:ac121993f5 merged revision(s) commit:21c6e8a54b. ---------------------------------------- Bug #22415: Thread.handle_interrupt needs to preserve errinfo https://bugs.ruby-lang.org/issues/22415#change-119872 * Author: rwstauner (Randy Stauner) * Status: Closed * Backport: 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ---------------------------------------- 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/