Repository navigation
Reset the class of each captured call - #10
Merged
samuel-williams-shopify merged 2 commits intoSep 29, 2026
Merged
Conversation
`Fiber_Profiler_Capture_Call_initialize` reset `id` but not `klass`, and `rb_frame_method_id_and_class` leaves `klass` untouched when there is no method frame (e.g. a block defined outside of a method, or GC outside of a method). Such calls reported whatever class was left in their slot: `false` for a fresh slot, or the class of an earlier call for a reused one. That earlier class is no longer marked by the capture, so it may have been freed or moved, and the report can show an unrelated object. Initialize `klass` to `nil` so these calls report `nil` instead.
samuel-williams-shopify
force-pushed
the
reset-call-class
branch
from
September 29, 2026 20:29
59fdda9 to
4c874fa
Compare
Contributor
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while investigating #7.
Fiber_Profiler_Capture_Call_initializeresetsidbut notklass. When there's no method frame, as with a block defined outside a method or a GC outside a method,rb_frame_method_id_and_classreturns false and leavesklassuntouched. So these calls report whatever class their slot held:falsefor a fresh slot, or an earlier call's class for a reused one.Once the earlier call is gone, the capture no longer marks that class, so it may have been freed or moved. After
GC.compactI've seen reports name unrelated objects, including strings whose quotes produced invalid JSON.Reproduction:
On
main(Ruby 4.0.7 and 3.4.10), the block on line 16 is reported asFoo, left over from the earlierFoo#bazcall:This change initializes
klasstonilalong withid, so both block calls are reported asnil, or<unknown>with #8.The added test runs a top-level block (inside
sus, everyitblock is itself within a method). It fails before the change, reporting["false", "String", "Kernel", "false", "Kernel"], and passes after. It doesn't depend on the label, so it works with or without #8.bundle exec sus: 41/41 on Ruby 4.0.7 (YJIT) and 3.4.10.