Skip to content

Commit 7dbe917

Browse files
radekdoulikCopilot
andcommitted
[wasm] Fix interpreter crash with MethodImpl .override on PortableEntryPoints
Resolve MethodImpl overrides in getCallInfo for direct calls when FEATURE_PORTABLE_ENTRYPOINTS is enabled. On non-WASM, this resolution happens in getFunctionEntryPoint via MapMethodDeclToMethodImpl, but that function is not available with portable entry points. Adding the resolution to getCallInfo ensures the interpreter compiler receives the correct target MethodDesc at compile time. This fixes a crash where a non-virtual call to a MethodImpl-overridden method (e.g. call instance MyBar::DoBar() with .override pointing to DoBarOverride) would target the wrong method, leading to uninitialized interpreter code. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 875672f commit 7dbe917

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/coreclr/vm/jitinterface.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5372,6 +5372,20 @@ void CEEInfo::getCallInfo(
53725372
#endif // STUB_DISPATCH_PORTABLE
53735373
}
53745374

5375+
#ifdef FEATURE_PORTABLE_ENTRYPOINTS
5376+
// On portable entry points, getFunctionEntryPoint is not available to resolve MethodImpl
5377+
// overrides. Do the resolution here so the interpreter compiler gets the right target
5378+
// method for non-virtual calls to MethodImpl-overridden methods.
5379+
if (directCall)
5380+
{
5381+
MethodDesc* pResolvedMD = MethodTable::MapMethodDeclToMethodImpl(pTargetMD);
5382+
if (pResolvedMD != pTargetMD)
5383+
{
5384+
pTargetMD = pResolvedMD;
5385+
}
5386+
}
5387+
#endif // FEATURE_PORTABLE_ENTRYPOINTS
5388+
53755389
pResult->hMethod = CORINFO_METHOD_HANDLE(pTargetMD);
53765390

53775391
pResult->accessAllowed = CORINFO_ACCESS_ALLOWED;

0 commit comments

Comments
 (0)