Project

General

Profile

Actions

Bug #22415

open

Thread.handle_interrupt needs to preserve errinfo

Bug #22415: Thread.handle_interrupt needs to preserve errinfo

Added by rwstauner (Randy Stauner) about 2 hours ago. Updated about 1 hour ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:126992]

Description

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:

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"
Actions

Also available in: PDF Atom