Skip to content

Commit abf21e2

Browse files
leculverCopilot
andauthored
Fix DumpIL error message for IL stubs (dotnet#5731)
IL stubs (P/Invoke and Reverse P/Invoke marshaling stubs) have a nil metadata token (0x06000000) and no IL body. The DumpIL command now detects this case early via IsNilToken and prints a clear message instead of the cryptic 'error decoding IL' / 'ilAddr is 0'. Also improved the fallback error message when GetILAddress fails for non-nil tokens. This is the right fix, as IL for stubs is freed after JIT'ing in FreeCompileTimeState. Sometimes they persist if the IL was put on the loader heap for a couple of specific stubs, but it's not worth building a big feature to display these in SOS, so we'll improve the message and be done. Fixes dotnet#3005 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f11183a commit abf21e2

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/SOS/Strike/strike.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,10 +790,16 @@ DECLARE_API(DumpIL)
790790
}
791791
else
792792
{
793+
if (IsNilToken(MethodDescData.MDToken))
794+
{
795+
ExtOut("This method has no IL body (e.g. IL stubs generated for P/Invoke or Reverse P/Invoke marshaling).\n");
796+
return S_OK;
797+
}
798+
793799
GetILAddressResult result = GetILAddress(MethodDescData);
794800
if (std::get<0>(result) == (TADDR)0)
795801
{
796-
ExtOut("ilAddr is %p\n", SOS_PTR(std::get<0>(result)));
802+
ExtOut("Unable to retrieve IL for this method (ilAddr is %p).\n", SOS_PTR(std::get<0>(result)));
797803
return E_FAIL;
798804
}
799805
ExtOut("ilAddr is %p pImport is %p\n", SOS_PTR(std::get<0>(result)), SOS_PTR(std::get<1>(result)));

0 commit comments

Comments
 (0)