From: "ko1 (Koichi Sasada) via ruby-core" Date: 2026-09-09T02:41:56+00:00 Subject: [ruby-core:126604] [Ruby Bug#20158] Ractor affects Coverage results Issue #20158 has been updated by ko1 (Koichi Sasada). Status changed from Assigned to Closed Re-checked: this is fixed, and it was fixed as #19112. I ran mame's rspec reproduction from #note-3 on four builds. The absolute event counts differ between versions because they load different numbers of files; what matters is the with/without-Ractor pair inside one version: ruby TracePoint :line events no Ractor / with Ractor 3.3.2 22741 / 8112 <- reproduces, stops inside rubygems 3.4.4 35621 / 12738 <- reproduces 4.0.2 52294 / 52325 <- fine master 4d185cce78 5432 / 5455 <- fine GH-15468 (`4fb537b1ee`, "Make tracepoints with set_trace_func or TracePoint.new ractor local", Fixes [Bug #19112]) is what fixed it: before that, GC'ing any Ractor object cleared the global event flags and every enabled tracepoint with them, which is exactly the "TracePoint stops firing part-way through" symptom here. Closing as a duplicate of #19112. Note that Coverage still does not record code executed inside a Ractor -- that is #20167, which is a different cause (the coverage hook is registered on the Ractor that called Coverage.start, and hook lists are per-Ractor) and stays open. ---------------------------------------- Bug #20158: Ractor affects Coverage results https://bugs.ruby-lang.org/issues/20158#change-118836 * Author: janosch-x (Janosch M�ller) * Status: Closed * Assignee: ractor * ruby -v: ruby 3.3.0preview1 (2023-05-12 master a1b01e7701) [arm64-darwin22] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- I have a large rspec test suite. I found that if I call a Ractor, the Coverage results are strongly affected, i.e. almost all files appear to be uncovered. This happens even if I only ever call a Ractor before the library or rspec are required. Unfortunately, I was not able to build a simple repro yet. I assume it is a timing thing and only affects larger suites, or it only happens if there are multiple files, and maybe if the library lazily requires its sub-modules? However, I guess this should produce the same results when added to the spec_helper.rb of other large suites: ```ruby # Ractor.new { nil } # uncomment this to affect coverage results require 'coverage' Coverage.start # require library, set up rspec etc. RSpec.configuration.after(:suite) do # this number is greatly reduced and unstable when calling Ractor above p Coverage.result.values.sum { |arr| arr.sum(&:to_i) } end ``` I had this problem in [this library](https://github.com/jaynetics/character_set/). The problem affects simplecov users as well, as described [here](https://github.com/simplecov-ruby/simplecov/issues/1058). -- 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/