You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[wasm][interp] conv.i8 of a managed pointer on 32-bit stops the runtime ("transform.c:1132", Store local stack type mismatch) or returns a garbage high word #137923
In Blazor WebAssembly (Mono interpreter, wasm32), (long) of an Unsafe.AsPointer result, inlined into a method, stops the
.NET runtime while the interpreter compiles that method. The browser console shows
and nothing in the page's .NET code runs after that. Where the converted value is not stored into a local, the conversion
instead returns a 64-bit value whose low 32 bits are right and whose high 32 bits are garbage.
[MethodImpl(MethodImplOptions.AggressiveInlining)]staticunsafelongAsPointerToLong(uintaddress)=>(long)(IntPtr)Unsafe.AsPointer(refUnsafe.AsRef<byte>((void*)address));for(intround=0;round<100_000;round++){uinta=2654435761u*(uint)(round+1)&0x7FFF_FFF0u;longgot=AsPointerToLong(a);// the runtime stops hereif(got!=a)wrong++;}
Expected behavior
got == a (the pointer is never dereferenced), as on desktop .NET and in the ahead-of-time compiled build.
Actual behavior
Build
Runtime
Result
.NET 10 default (interpreter + jiterpreter), the live page (built by GitHub Actions)
10.0.15
runtime stops, transform.c:1132
.NET 10 default (interpreter + jiterpreter)
10.0.14
runtime stops, transform.c:1132
.NET 10 interpreter only (BlazorWebAssemblyJiterpreter=false)
10.0.14
runtime stops, transform.c:1132
.NET 10 ahead-of-time (RunAOTCompilation)
10.0.14
right (100,000 of 100,000)
.NET 9 default
9.0.22
runtime stops, transform.c:1132
.NET 8 default
8.0.33
runtime stops, transform.c:1146
Controls on the same page are right in every build: (long)(ulong)Unsafe.AsPointer(...) (conv.u8), (long)(nint)address,
and the same (long)(IntPtr)Unsafe.AsPointer(...) in its own [NoInlining] method.
Windows 11, Chrome 157.
Regression?
Not a recent one: .NET 8, 9 and 10 behave the same.
Known Workarounds
Avoid conv.i8 of a managed pointer: convert through (ulong) / (nuint), or compute addresses with integer arithmetic.
interp_add_ins adds the instruction without source/destination registers and the stack entry keeps its 4-byte MP type.
The CEE_CONV_U8 MP case (L6671)
uses interp_add_conv (td, td->sp - 1, STACK_TYPE_I8, MINT_CONV_I8_U4);.
Stored into a long local, store_local then hits g_error ("%s.%s: Store local stack type mismatch %d %d", ...)
(L1130); its implicit
nint/int32 conversions are #if SIZEOF_VOID_P == 8 only.
The likely fix: interp_add_conv (td, td->sp - 1, STACK_TYPE_I8, MINT_CONV_I8_I4); in that case.
Found in SpawnDev.ILGPU, where a device copy computed (long)view.LoadEffectiveAddressAsPtr() (new IntPtr(Unsafe.AsPointer(ref ...)))
and, in a busy page (after tier-up inlining), got offsets such as 30064771072 (= 7 * 2^32) and 412316860744 (= 96 * 2^32 + 328):
right low word, garbage high word. It now computes the address with integer arithmetic.
Activity
Link dotnet/runtime#137923; the live page's .NET 10.0.15 result
dotnet-policy-service commentedon Nov 19, 2026
Tagging subscribers to this area: @vitek-karas, @BrzVlad, @kotlarmilos
See info in area-owners.md if you want to be subscribed.
5.4.40 (forks 2.4.36): a view's effective address is integer arithmet…
kotlarmilos commentedon Nov 20, 2026
@pavelsavara Could you please take a look?
dotnet-policy-service commentedon Nov 20, 2026
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.