Skip to content

[wasm][coreclr] GetUnmanagedCallersOnlyThunk: unknown thunk for unmanaged callers only method #124219

Open

Description

@radekdoulik

Some runtime tests have methods decorated with UnmanagedCallersOnly attribute. These will require native relinking.

They fail like this:

11:48:33.449 Running test: JIT/opt/Regressions/Regression3_Regressions/Regression3_Regressions.dll
ASSERT FAILED
	Expression: false && "GetUnmanagedCallersOnlyThunk: unknown thunk for unmanaged callers only method"
	Location:   /__w/1/s/src/coreclr/vm/wasm/helpers.cpp:746
	Function:   GetUnmanagedCallersOnlyThunk
	Process:    42
Frame (InlinedCallFrame): 0x4fdc54
    Skipping 0x4fdc54
Frame (InterpreterFrame): 0x4fede8
   0) dynamicClass::IL_STUB_PInvoke, IR_004a
   1) System.Reflection.RuntimeAssembly::GetTypeCore, IR_015c
   2) System.Reflection.RuntimeAssembly::GetTypeCore, IR_006d
   3) System.Reflection.TypeNameResolver::GetType, IR_0278
   4) System.Reflection.TypeNameResolver::GetSimpleType, IR_00bb
   5) System.Reflection.TypeNameResolver::Resolve, IR_0018
   6) System.Reflection.TypeNameResolver::GetType, IR_0099
   7) System.Reflection.RuntimeAssembly::GetType, IR_002a
   8) System.Reflection.Assembly::GetType, IR_001b
   9) Program::TestEntryPoint, IR_002e
  10) Program::<<Main>$>g__TestExecutor134|0_135, IR_005b
  11) Program::<Main>$, IR_07b9

Activity

  1. added this to the Future milestone on Feb 10, 2026
  2. dotnet-policy-service commented on Feb 10, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
    See info in area-owners.md if you want to be subscribed.

  3. dotnet-policy-service commented on Feb 10, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @agocke
    See info in area-owners.md if you want to be subscribed.

  4. lewing commented on Jul 15, 2026

    @lewing
    Member

    Status (still valid): the assert is intact at src/coreclr/vm/wasm/helpers.cpp:1489 (GetUnmanagedCallersOnlyThunk: unknown thunk ...), fired when LookupThunk(pMD) finds no reverse-thunk for a [UnmanagedCallersOnly] method. Runtime tests (src/tests) still have no per-test native relink, so they run against the baked libcoreclr_gen_static.a table (generated at runtime-build time) and hit this for any test-introduced UCO method.

    Currently gating these wasm runtime tests via [ActiveIssue(#124219, IsWasm)]:

    • src/tests/Loader/classloader/Casting/Functionpointer.cs
    • src/tests/JIT/opt/Regressions/Regression3_Regressions.cs
    • src/tests/JIT/Regression/JitBlue/Runtime_72265/Runtime_72265.cs
    • src/tests/JIT/Regression/JitBlue/Runtime_105619/Runtime_105619.cs

    Path to resolution: the fix is the per-app native relink noted in the description. That mechanism now exists for library tests — #130129 / src/mono/wasi/build/WasiApp.CoreCLR.targets runs ManagedToNativeGenerator over the bundle, compiles the generated callhelpers, and relinks the host swapping out the baked coreclr_gen_static (validated: full System.Runtime.Tests suite runs on a relinked corerun). Extending the same relink to the src/tests build would cover runtime-test UCO methods and let the four [ActiveIssue]s above be re-enabled.

    Companion fix: #130740 corrects the reverse-thunk key for nested [UnmanagedCallersOnly] types (reflection namespace vs empty metadata namespace) — nested UCO callbacks in runtime tests would still miss even after relinking without it. Distinct from #130634 (R2R call_indirect).

    Note

    This comment was drafted with GitHub Copilot.

  5. added
    disabled-testThe test is disabled in source code against the issue
    on Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-wasmWebAssembly architecturearea-VM-coreclrdisabled-testThe test is disabled in source code against the issue

Type

No type

Projects

  • Status
    No status

Relationships

None yet

Development

No branches or pull requests

Issue actions