-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix DebugInfo async local var number #122148
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
base: main
Are you sure you want to change the base?
Fix DebugInfo async local var number #122148
Conversation
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 fixes a critical bug in the JIT compiler's debug info generation where async methods with multiple hidden parameters (specifically async continuation and generic type context) would produce duplicate IL variable numbers.
Key Changes:
- Introduced
originalVarNumto preserve the input value during hidden parameter processing - Updated all four hidden parameter checks to use
originalVarNumfor comparisons instead of the mutatingvarNum
jakobbotsch
left a comment
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.
Thanks for finding this.
|
Tagging subscribers to this area: @steveisok, @dotnet/dotnet-diag |
Bug when both an
asyncContinuationArgandcompTypeCtxtArgare present due to mutating value used for comparison.There are four separate checks for special parameters which are hidden and decrement the actual var number. These are:
Previously, the value would be decremented then compared in the order listed. This causes problems if multiple of these hidden parameters are present since the decremented value would be equal or lower to the hidden var number and would not be decremented.
Example - Async method with a hidden generic type context:
Both the type context and async continuation hidden vars are present:
info.compTypeCtxtArg = 1and
lvaAsyncContinuationArg = 2For
varNum = 3:varNum > info.compTypeCtxtArg -> 3 > 2 -> trueand thereforevarNumis decremented to2varNum > lvaAsyncContinuationArg -> 2 > 2 -> falseand thereforevarNumis not decremented.2For
varNum = 4:varNum > info.compTypeCtxtArg -> 4 > 2 -> trueand thereforevarNumis decremented to3varNum > lvaAsyncContinuationArg -> 3 > 2 -> trueand thereforevarNumis decremented to2.2This leads to two
AsyncContinuationVarInfoboth havingVarNumber = 2