Skip to content

[wasm] CORINFO_HELP_CHECK_OBJ is modeled TYP_VOID in fgMorphInit but JIT_CheckObj returns Object* #131378

Description

@lewing

Description

CORINFO_HELP_CHECK_OBJ is implemented as HCIMPL1_RAW(Object*, JIT_CheckObj, Object* obj) in src/coreclr/vm/jithelpers.cpp — it returns Object*. The JIT models it inconsistently:

  • src/coreclr/jit/importer.cpp (return-value check): gtNewHelperCallNode(CORINFO_HELP_CHECK_OBJ, TYP_REF, op2) — correct.
  • src/coreclr/jit/morph.cpp (fgMorphInit, argument check): gtNewHelperCallNode(CORINFO_HELP_CHECK_OBJ, TYP_VOID, op) — models a value-returning helper as void.

On register-based targets the second form is benign (the returned reference is simply left in the return register and dropped). On wasm the call_indirect / call signature is derived from the JIT-modeled return type in CodeGen::genCallInstruction, so a TYP_VOID model for a value-returning helper emits a mismatched signature and the engine traps with function signature mismatch — the same class of defect as #130813 and the inline-unbox slow-path helper.

This only fires under DOTNET_JitGCChecks=1 (opts.compGcChecks) in a Debug/Checked JIT, so it is low severity, but it is the same modeling bug and is cheap to fix.

Reproduction Steps

Checked/Debug JIT, DOTNET_JitGCChecks=1, wasm target, on any method with a TYP_REF argument.

Expected behavior

The helper is modeled with a return type matching JIT_CheckObj (TYP_REF), and the unused result is discarded (e.g. via gtUnusedValNode) so the enclosing statement stays void.

Actual behavior

fgMorphInit creates the call as TYP_VOID; on wasm the emitted call signature does not match the helper.

Configuration

browser-wasm / wasi-wasm, Checked/Debug, DOTNET_JitGCChecks=1, main.

Related: #129622, #130813

Note

This issue was created with assistance from GitHub Copilot (AI).

Metadata

Metadata

Assignees

No one assigned

    Labels

    arch-wasmWebAssembly architecturearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIuntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions