Skip to content

[release/9.0-preview2] Fix unwound stack range check for the new EH#99043

Closed
github-actions[bot] wants to merge 1 commit intorelease/9.0-preview2from
backport/pr-99041-to-release/9.0-preview2
Closed

[release/9.0-preview2] Fix unwound stack range check for the new EH#99043
github-actions[bot] wants to merge 1 commit intorelease/9.0-preview2from
backport/pr-99041-to-release/9.0-preview2

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Feb 28, 2024

Backport of #99041 to release/9.0-preview2

/cc @janvorli

Customer Impact

  • Customer reported
  • Found internally

When a customer code is using dynamic methods on ARM64, which can be indirect (e.g. by using reflection invoke at least in some cases), the GC stack walk can miss the dynamic method during exception handling and not report it to the GC. The method then gets collected, destroyed and a follow up GC / EH stack walk crashes when trying to get information on it.

Regression

  • Yes
  • No

#98570 - enables the new exception handling by default.

Testing

Local testing and debugging of the tests that have failed due to the problem. Without the fix, it was reproducing on almost every run of a coreclr test

Risk

Low, fixes a clearly incorrect range check.

With the old EH, the unwound stack range limits are using SP for each
frame on x64 and a caller SP on arm64, arm, riscv64 and longsoon.
The ExceptionTracker::IsInStackRegionUnwoundBySpecifiedException takes
that into consideration when detecting whether a frame with a specific
SP was already unwound or not.
With the new EH though, the range is always based on the actual SP of
the frame, so the check was being done incorrectly on non-x64
architectures.
That lead to a crash in a test that has dynamic method code on stack
and its frame was unwound. The bug has caused that method to not to be
reported to GC, so the dynamic method was destroyed by GC. And later on,
another GC stack walk has crashed while trying to get info on the
method.
This change fixes it by making the check with new EH enabled the same
for all architectures, the same as it was for x64 in the old EH.

Close #98914
@jkotas
Copy link
Copy Markdown
Member

jkotas commented Feb 28, 2024

Superseded by #99067

@jkotas jkotas closed this Feb 28, 2024
@jkotas jkotas deleted the backport/pr-99041-to-release/9.0-preview2 branch February 28, 2024 18:17
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-ExceptionHandling-coreclr Servicing-consider Issue for next servicing release review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants