-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Zero initialize FrameInfo so that we don't mistake an InlineCallFrame for a CLRToCOMMethodFrame #117252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… for a CLRToCOMMethodFrame
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures a FrameInfo
struct is zero-initialized in TrackUMChain
to avoid uninitialized boolean flags causing incorrect debugger stepping behavior when static constructors haven’t run.
- Value-initialize
FrameInfo f
sofIgnoreThisFrameIfSuppressingUMChainFromCLRToCOMMethodFrameGeneric
is false by default. - Prevents the debugger from mistaking an
InlineCallFrame
for aCLRToCOMMethodFrame
and stepping out incorrectly.
Comments suppressed due to low confidence (1)
src/coreclr/debug/ee/frameinfo.cpp:1182
- Add a debugger stepping test to verify that
FrameInfo
is correctly zero-initialized and thatInlineCallFrame
s are not mistaken forCLRToCOMMethodFrame
after this change.
FrameInfo f = {};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
/ba-g Infra failure is too generic on win-x86 legs |
Tagging subscribers to this area: @steveisok, @dotnet/dotnet-diag |
Hi @steveisok , a quick question related to logging. How do I enable logging for stackwalker and GC? I tried |
This one was a doozy.
If you try to step in to a static function and the static cctor hasn't run, the debugger will treat it as a go. Moving the static helpers to managed altered the debugger flow such that you would have managed -> native interop -> managed (implied .cctor) frames. The debugger would detect the last managed one is an implied .cctor and step out. When it stepped out to the next managed frame, it would then incorrectly calculate the offset and issue a breakpoint the instruction before the qcall into native code. Thus, the code already ran and it's effectively a go.
After a bunch of logging and discussion, I at first thought the stackwalker was at fault where it somehow ignored the unmanaged frames. I then noticed we have a block that intentionally suppresses native frames when stepping out similar to what is now happening.
After even more logging, I noticed that
pInfo->fIgnoreThisFrameIfSuppressingUMChainFromCLRToCOMMethodFrameGeneric
was true even though nothing ran to set it that way. This lead to the fix where we zero initialize aFrameInfo
instance to make sure that bool is false.Note: I would not be surprised if there are other interop stepping issues lurking. Additionally, there are other places where we don't zero initialize various structs on the stack. As a follow up, we should do that in order to avoid this kind of madness.
Fixes #114820