-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix minidump generation when there is a NDirect method in the stack #116391
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 minidump generation when there is a NDirect method in the stack #116391
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 aims to fix minidump generation by avoiding retrieval of IL from the PE for NDirect methods, since their IL is dynamically generated.
- Added an extra check (!IsNDirect()) before attempting to retrieve the IL header.
- Ensures that the IL header is only fetched for non-NDirect methods.
Comments suppressed due to low confidence (1)
src/coreclr/vm/method.cpp:1211
- [nitpick] Consider adding a brief comment explaining that NDirect methods generate dynamic IL and therefore do not require IL header retrieval from the PE. This could enhance code clarity for future maintainers.
if (pIL == (TADDR)NULL && !IsNDirect())
Tagging subscribers to this area: @tommcdon |
Could you please share stacktrace for the crash that this is fixing? I do not see the problem with the current code. GetRVA should return 0 for (NDirect) P/Invoke methods. Module::GetIL has early our for RVA == 0. If there is a problem with this path, there are likely more types of methods that we need to check here (e.g. FCalls, etc.). |
@@ -1208,7 +1208,7 @@ COR_ILMETHOD* MethodDesc::GetILHeader() | |||
// Always pickup overrides like reflection emit, EnC, etc. |
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.
Notice that this method has a PRECONDITION(IsIL())
. It means that it is not expected to be called on IsNDirect
method in the first place.
I think the correct fix is to add if (IsIL())
check around the whole CodeVersionManager related block in MethodDesc::EnumMemoryRegions
.
One possible explanation is that this is IJW module (are you able to confirm it with the customer?) and GetRVA returns the address of native code in that case. We try to interpret the native code as IL and crash. |
Confirmed that it is an IJW app |
Only get the il from PE if it's not nDirect Method because the IL of a NDirect is dynamically generated so it does not make sense to get it from the PE.