From: "yokomaru (Yoko Suzuki) via ruby-core" Date: 2026-08-04T05:45:39+00:00 Subject: [ruby-core:126240] [Ruby Bug#22217] Segmentation fault when resuming execution with `Coverage.start` and ruby/debug Issue #22217 has been updated by yokomaru (Yoko Suzuki). Thank you so much for the quick fix and for preparing the backport! ---------------------------------------- Bug #22217: Segmentation fault when resuming execution with `Coverage.start` and ruby/debug https://bugs.ruby-lang.org/issues/22217#change-118326 * Author: yokomaru (Yoko Suzuki) * Status: Closed * Assignee: luke-gru (Luke Gruber) * Target version: 4.0 * ruby -v: ruby 4.1.0dev (2026-07-29T23:49:57Z master 94933bfebf) +PRISM [arm64-darwin25],ruby 4.1.0dev (2026-07-29T23:49:57Z master 94933bfebf) +PRISM [x86_64-linux],ruby 4.0.6 (2026-07-14 revision 03b6d3f889) +PRISM [arm64-darwin25],ruby 4.0.6 (2026-07-14 revision 03b6d3f889) +PRISM [x86_64-linux] * Backport: 4.0: REQUIRED ---------------------------------------- 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` ```ruby require "coverage" Coverage.start require "debug" debugger ``` ## Steps to Reproduce Run: ```console $ ruby test.rb ``` At the debugger prompt, enter: ```text continue ``` 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: ```text 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: ```text 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-------------------------------- test.rb (62 Bytes) stderr-macos-4.1-dev.log (35.7 KB) stderr-linux-4.1-dev.log (35.4 KB) ruby-2026-07-30-112302.ips (15 KB) -- 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/