Skip to content

[wasm][coreclr] TypeLoadException during type loading #127426

@radekdoulik

Description

@radekdoulik

@davidwrighton this is the regression in priority1 test from #126901

Few tests in Methodical_*.csproj priority1 are failing with:

Unhandled exception. System.TypeLoadException: Could not load type 'JitTest_call_cs.VT' from assembly 'Methodical_d2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
   at Program.<Main>$(String[] args) in /Users/rodo/git/runtime-r2r-pe/artifacts/tests/coreclr/obj/browser.wasm.Debug/Managed/JIT/Methodical/Methodical_d2/generated/XUnitWrapperGenerator/XUnitWrapperGenerator.XUnitWrapperGenerator/FullRunner.g.cs:line 319
   at System.Environment.CallEntryPoint(IntPtr entryPoint, String[]* pArgument, Int32* pReturnValue, Boolean captureException, Exception* pException)
Aborted(native code called abort())

Standalone repro: https://gist.github.com/radekdoulik/b12c12fb2327ff56b839a9f0ba752724

Temporary workaround:

diff --git a/src/coreclr/vm/wasm/helpers.cpp b/src/coreclr/vm/wasm/helpers.cpp
index bcc93890591..f25dd7a83ba 100644
--- a/src/coreclr/vm/wasm/helpers.cpp
+++ b/src/coreclr/vm/wasm/helpers.cpp
@@ -1146,6 +1146,12 @@ void* GetPortableEntryPointToInterpreterThunk(MethodDesc *pMD)
         return NULL;
     }
 
+    MethodTable* pMT = pMD->GetMethodTable();
+    if (pMT != NULL && !pMT->IsFullyLoaded())
+    {
+        return NULL;
+    }
+

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions