From: "nagachika (Tomoyuki Chikanaga) via ruby-core" Date: 2026-09-06T07:56:49+00:00 Subject: [ruby-core:126578] [Ruby Bug#22269] `Coverage.line_stub` clobbers already-collected coverage data Issue #22269 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.3: UNKNOWN, 3.4: DONE, 4.0: DONE merged backport PR: https://github.com/ruby/ruby/pull/18584 ---------------------------------------- Bug #22269: `Coverage.line_stub` clobbers already-collected coverage data https://bugs.ruby-lang.org/issues/22269#change-118788 * Author: mugikurash (Shuta Mugikura) * Status: Closed * ruby -v: ruby 4.1.0dev (2026-08-27T01:47:31Z master 5ee95de080) +PRISM [arm64-darwin25] * Backport: 3.3: UNKNOWN, 3.4: DONE, 4.0: DONE ---------------------------------------- `Coverage.line_stub` compiles the file with `compile_file` only to read the ISeq's `trace_points`. Since https://bugs.ruby-lang.org/issues/22018 `compile_file` registers the file into the coverage table, so calling `line_stub` while `Coverage` is running resets the file's already-collected counters. This also reproduces on 3.4 and 4.0, so I would like it backported. Reproduction: ```ruby require "coverage" f = File.expand_path("m.rb") File.write(f, "def m\n :ok\nend\n") Coverage.start require f m p Coverage.peek_result[f] Coverage.line_stub(f) p Coverage.peek_result[f] m p Coverage.result[f] ``` Expected: ``` [1, 1, nil] [1, 1, nil] [1, 2, nil] ``` Actual: ``` [1, 1, nil] [0, 0, nil] [0, 0, nil] ``` -- 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/