Bug #22217
closedSegmentation fault when resuming execution with `Coverage.start` and ruby/debug
Description
Resuming execution from ruby/debug while coverage collection is enabled via Coverage.start can cause a segmentation fault and crash the Ruby process.
The crash is intermittent, but reproduces frequently using the same steps. I confirmed it on both macOS (arm64) and Linux (x86_64) using debug 1.11.1. It reproduced with Ruby 4.0.5, Ruby 4.0.6, and Ruby 4.1.0-dev, but did not reproduce in my limited testing with Ruby 3.4.10 or Ruby 3.3.12.
Reproduction Code¶
test.rb
Steps to Reproduce¶
Run:
At the debugger prompt, enter:
The same crash also occurs with next, step, and finish.
Backtrace Excerpt¶
Both macOS and Linux crash around the Ruby VM event hooks.
On macOS (arm64), the C-level backtrace includes:
libruby.4.1.dylib(exec_hooks_protected+0xb0)
libruby.4.1.dylib(rb_exec_event_hooks+0x7c)
libruby.4.1.dylib(vm_trace_hook+0x198)
libruby.4.1.dylib(vm_trace+0x24c)
On Linux (x86_64), it includes:
libruby.so.4.1(exec_hooks_body+0x20) vm_trace.c:453
libruby.so.4.1(exec_hooks_protected+0x10b) vm_trace.c:515
libruby.so.4.1(rb_exec_event_hooks+0x83) vm_trace.c:562
libruby.so.4.1(vm_trace_hook+0x17c) vm_core.h:2376
libruby.so.4.1(vm_trace+0x344) vm_insnhelper.c:7373
I've attached the crash log from the latest version (4.1.0-dev).
Files