-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Fix Windows Arm64 unwinding #102258
Fix Windows Arm64 unwinding #102258
Conversation
There was an issue with unwinding native code functions in case of calls to no-return function placed at an end of a function code block. The return address was not in range of the function code, so RtlLookupFunctionEntry was not finding anything, we were thinking that it was a leaf function due to that and tried to unwind using LR only, which was wrong and resulted in staying on the same instruction. Thus the unwinding ended up in an infinite loop for those cases. The fix, that matches what RtlUnwind does, is to adjust the instruction pointer at call sites back. This is arm64 specific. Close dotnet#101921
Tagging subscribers to this area: @mangod9 |
src/coreclr/vm/stackwalk.cpp
Outdated
@@ -553,6 +553,13 @@ PCODE Thread::VirtualUnwindCallFrame(T_CONTEXT* pContext, | |||
UINT_PTR uImageBase; | |||
PT_RUNTIME_FUNCTION pFunctionEntry; | |||
|
|||
#if !defined(TARGET_UNIX) && defined(CONTEXT_UNWOUND_TO_CALL) |
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.
When is CONTEXT_UNWOUND_TO_CALL
not defined on Windows here?
I see CONTEXT_UNWOUND_TO_CALL
defined for both x64 and arm64 in Windows SDK.
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.
Hmm, that's strange. In pal.h we don't define it for x64 and Windows also doesn't set it for non-arm.
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.
I've added a commit to change that ifdef to TARGET_ARM64
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
* Fix Windows Arm64 unwinding There was an issue with unwinding native code functions in case of calls to no-return function placed at an end of a function code block. The return address was not in range of the function code, so RtlLookupFunctionEntry was not finding anything, we were thinking that it was a leaf function due to that and tried to unwind using LR only, which was wrong and resulted in staying on the same instruction. Thus the unwinding ended up in an infinite loop for those cases. The fix, that matches what RtlUnwind does, is to adjust the instruction pointer at call sites back. This is arm64 specific. Close dotnet#101921 * Modify the ifdef from CONTEXT_UNWOUND_TO_CALL to TARGET_ARM64
There was an issue with unwinding native code functions in case of calls to no-return function placed at an end of a function code block. The return address was not in range of the function code, so RtlLookupFunctionEntry was not finding anything, we were thinking that it was a leaf function due to that and tried to unwind using LR only, which was wrong and resulted in staying on the same instruction. Thus the unwinding ended up in an infinite loop for those cases. The fix, that matches what RtlUnwind does, is to adjust the instruction pointer at call sites back. This is arm64 specific.
Close #101921