Repository navigation
Don't inspect hidden classes when printing captured calls - #9
Closed
trevorturk wants to merge 1 commit into
Closed
trevorturk wants to merge 1 commit into
trevorturk wants to merge 1 commit into
Conversation
When a GC starts inside a method defined on a hidden class, such as the
singleton class of `RubyVM::FrozenCore` (which implements `->{}`, `**`
hash merges and similar), `rb_frame_method_id_and_class` returns that
hidden class as the owner of the GC call. Printing the report then
called `rb_inspect` on it, which raises `NotImplementedError` out of the
fiber switch hook and into whatever resumed the fiber.
Use `rb_class_path` for hidden classes instead, which doesn't dispatch
a method on the class.
Fixes socketry#7.
Author
|
Closing in favor of #8. I left validation results, a suggested tweak and tests there. |
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.
Fixes #7.
Problem
In capture mode, printing a stall can raise
NotImplementedError: method 'inspect' called on hidden T_CLASS objectfrom the fiber-switch hook. The exception escapes into whatever resumed the fiber (the scheduler'sselectunder Async/Falcon), which kills the worker.Cause
CRuby defines its internal helpers for
->{},**hash merges,aliasand similar on the singleton class ofRubyVM::FrozenCore, and hides that class (RBASIC_CLEAR_CLASSinInit_VM). CRuby skips regular trace events for FrozenCore, but not internal GC events. When a GC starts during one of these helpers,rb_frame_method_id_and_classin theGC_STARThook returns the hidden class, andrb_inspecton it raises.Fix
When the class is hidden, both the TTY and JSON printers use
rb_class_pathinstead ofrb_inspect, which doesn't dispatch a method on the class. Such calls now print as e.g.#<Class:0x…>#lambda.Testing
GC.stress. Onmainit aborts the run with theNotImplementedError; with this change it passes.bundle exec sus: 41/41 passing on Ruby 4.0.7 (with YJIT) and 3.4.10.