Repository navigation
Description
Description
Under profile-guided partial AOT (RunAOTCompilation=true + WasmAotProfilePath, profile-only method set), a browser-wasm app intermittently hits a Mono metadata assertion:
[MONO] * Assertion at /__w/1/s/src/runtime/src/mono/mono/metadata/class-accessors.c:90, condition `<disabled>' not met
with two observable failure shapes from the same defect:
- Silent managed-task death — the assert fires, the executing managed continuation dies, the app keeps running but the work it was doing is lost (in our app: a server-sync apply loop dies, leaving a permanently empty UI).
- Uninterruptible 100%-CPU hang — the renderer main thread enters a call-free wasm loop that V8 cannot interrupt (no stack check on call-free back edges): CDP
Profiler.startandDebugger.pauseboth time out,Runtime.evaluatenever returns, one thread pins a core indefinitely.
The correlation between the assert and the hang is direct: in 3 of 5 captured hangs, the assert's console timestamp equals the hang onset to the second (the other two hangs froze without getting the assert line out).
The same workload has never exhibited either failure under the interpreter (no AOT, identical bundle otherwise), nor with the jiterpreter — see the A/B arm below — nor on the same framework's WPF/Android (non-wasm) heads.
At the v10.0.9 tag the nearest assertion to the reported line is g_assert (klass) in mono_class_get_flags (class-accessors.c:89; the CI build path suggests a servicing-branch build, so ±1 line drift) — i.e. a NULL MonoClass* reaching mono_class_get_flags.
Reproduction Steps
We cannot share a minimal repro (the app is a large private codebase), but the failure is statistically reliable and quick under an automated soak:
- App: Blazor-less
Microsoft.NET.Sdk.BlazorWebAssembly-style browser-wasm head (WebSocket client + UI framework; STJ serialization; no threading, noInvokeAsyncmarshalling beyond the JS module interop). - Publish:
dotnet publish -c Release -p:RunAOTCompilation=true -p:WasmAotProfilePath=<recorded profile> -p:WasmStripILAfterAOT=false(profile recorded withWasmProfilers=aot). - Drive the app in a headless-Chrome loop (open app → open list-heavy views → navigate back, ~45s/cycle). The failure always strikes while the client is consuming a large burst of inbound WebSocket messages (initial sync or a view-open message burst) — i.e. deserialization + data-structure churn on the main thread.
- Frequency: 5 hangs in ~40 cycles across 3 runs (first at cycle 9), plus several assert-with-silent-death boots. A 30-minute soak has been decisive every time.
We can privately share: a stacks-only minidump of the spinning renderer process, CDP CPU/process samples, console rings with the assert + wasm stacks, and the soak driver.
Expected behavior
Partial AOT (profile-guided) behaves like the interpreter: no metadata asserts, no hangs.
Actual behavior
Intermittent class-accessors.c:90 assert; depending on where it strikes, silent loss of the executing task or a permanent uninterruptible 100%-CPU wasm loop.
Regression?
Unknown — this is our first use of AOT on this workload (interpreter has been stable for months on the same code).
Known Workarounds
None that keep AOT:
- Interpreter-only publish: never reproduces.
- Disabling all jiterpreter tiers (
--no-jiterpreter-traces-enabled --no-jiterpreter-interp-entry-enabled --no-jiterpreter-jit-call-enabled) on the AOT build: reproduces identically (hang at cycle 3, same RIP signature) — the loop is in V8-compileddotnet.native.wasm, not a jiterpreter trace module.
Configuration
- .NET SDK 10.0.301,
wasm-toolsworkload 10.0.109 - Runtime pack
Microsoft.NETCore.App.Runtime.Mono.browser-wasm10.0.9 - Emscripten 3.1.56 (pack 10.0.9)
- Chrome 150.0.7871.102 (headless and headed both affected), Windows 11 x64 host
- Single-threaded wasm (no
WasmEnableThreads)
Other information
Assert + wasm stack as captured (release runtime, so symbols are function indices only; happy to run a symbolicated build if that helps):
2026-07-12T21:18:55.985Z [MONO] * Assertion at /__w/1/s/src/runtime/src/mono/mono/metadata/class-accessors.c:90, condition `<disabled>' not met
Error
at Mc (dotnet.runtime.a6jcqbs390.js:3:172283)
at dotnet.native.tozcon2nad.wasm:wasm-function[46977]:0x9fbf84
at dotnet.native.tozcon2nad.wasm:wasm-function[35492]:0x815b40
at dotnet.native.tozcon2nad.wasm:wasm-function[35397]:0x813d0f
at dotnet.native.tozcon2nad.wasm:wasm-function[35401]:0x813e40
at dotnet.native.tozcon2nad.wasm:wasm-function[35403]:0x813e87
at dotnet.native.tozcon2nad.wasm:wasm-function[35402]:0x813e58
at dotnet.native.tozcon2nad.wasm:wasm-function[36507]:0x849e23
at dotnet.native.tozcon2nad.wasm:wasm-function[38994]:0x8c1f53
at dotnet.native.tozcon2nad.wasm:wasm-function[39300]:0x8d3989
Hang forensics (why we're confident this is a runtime-internal loop, not an app loop):
- Live RIP sampling of the spinning thread (
GetThreadContext× 40 @ 100ms): every sample lands in a ~500–700 byte window of anonymous executable memory (V8-JITted wasm; all chrome module ranges elsewhere), showing two hot basic blocks — the profile of a tiny probe loop over a corrupted runtime structure (e.g. a hash-table probe chain or a linked list made circular), not application logic. - The app's own re-scheduling paths all hop through
queueMicrotask/setTimeout, so an app-level loop keeps the event loop alive; here a single synchronous turn never ends. - CDP
Profiler.enable/startandDebugger.enable/pauseboth time out against the wedged renderer — consistent with a call-free wasm loop (no interrupt check on the back edge).
Related (same file/family, none an exact match): #45304 (:83, .NET 6 FullAOT), #65957 (:89, .NET 7 CI), #64774 (:92, .NET 7 CI), #63749 (GC filler class, wasm AOT), #120883 / #121738 (:93 "should not be reached", .NET 10, debugger-attach path — different assert and trigger).
Full trip diagnosis (timeline, A/B arms, per-trip histogram)
- Trip histogram across 5 hangs: always during an inbound message burst following a view-open action; server logs show the wedged client's last wire send is the post-open sync request, then ~55 outbound messages ship and the client never requests again.
- Timeline of the first captured trip (one browser process, three page sessions):
- Session 1 boots → assert fires during initial sync → session keeps running but the sync apply task died silently (empty data, UI never populates) → driver reloads.
- Session 2 boots clean; 8 cycles run normally.
- Cycle 9: view-open click → renderer main thread never returns; heartbeat (20s
Runtime.evaluate) fails twice → trip declared 42s after the click.
- CPU: renderer process pinned at 97–99% of one core from the first post-trip sample onward; a single thread owns ~98% (525 CPU-seconds accumulated by capture time).
- Jiterpreter-disabled arm: tripped identically at cycle 3 (fresh JIT address, same anonymous-window RIP signature, 40/40 samples).
- Interpreter arm (same app, no AOT): zero occurrences ever, including months of daily development use.
Activity
pavelsavara commentedon Jul 16, 2026
@benpetermorris
Does full AOT work fine ? Partial PGO was never supported feature on Mono AOT WASM.
I'm afraid that we can't make much progress without better repro.
benpetermorris commentedon Jul 18, 2026
@pavelsavara Gotcha. I reran the test without PGO and still experienced a hard failure, although at a lower incidence than before. Fable's summary follows.
As mentioned this is a large codebase, but since this is a blocker for my app I can provide a compiled wasm+test script bundle and/or continue to give more info if you can think of any that would help.
Short version: full (non-PGO) AOT does not work fine either, though it fails less often and only in the hang shape; and we now have a symbolicated native stack for the assert that names the failing runtime path.
1. Full AOT soak (same app, same automated driver, fresh server per run)
SDK 10.0.302, wasm-tools 10.0.109, WebAssembly SDK pack 10.0.9, Chrome 150.0.7871.116 headless, Windows 11 / i9-12900K. Publish:
dotnet publish -c Release -p:RunAOTCompilation=true(noWasmAotProfilePath, no IL strip; 47.9 MB dotnet.native.wasm).The full-AOT incident was the hard shape: renderer main thread uninterruptible (no CDP dispatch), page DOM-silent, killed by our run timeout — same site in the scenario sequence (an app-open right after a large inbound WebSocket burst) as the partial-AOT hangs. Two more full-AOT runs showed 12–17 s stalls at the same point that recovered on their own. So the hang family reproduces on the supported configuration, at lower incidence; the metadata assert appears to be partial-AOT-specific (or partial-AOT-amplified).
2. Symbolicated assert stack (partial AOT,
-p:WasmEmitSymbolMap=true)Captured twice this pass with identical frames (and identical to two captures on a previous same-source publish — the build is deterministic here):
i.e. AOT virtual-call resolution —
resolve_vcall→mono_aot_get_method_from_vt_slot— handsmono_class_get_flagsa NULL class. (V8's default 10-frame limit truncates the managed caller belowresolve_vcall; we can re-capture with a raisedError.stackTraceLimitif the deeper frames would help.) Fits the profile-only posture: mixed AOT/interpreter vtables are exactly where partial AOT differs from full AOT, and full AOT never asserted in our runs.3. New behavioral detail on the two shapes
Mid-hang CPU profiles (CDP
Profiler, 8 s @ 250 µs) on four of the five most recent partial-AOT incidents show the main thread 99.6–100 % idle — in those runs the managed work simply died/stalled (matching the "silent managed-task death" shape; two of the four also logged the assert + ".NET runtime already exited with 1"). Only the fifth incident was the spin: CDP entirely unresponsive, consistent with the call-free-loop analysis in the issue body. So: assert → runtime dead / task lost (thread idle) vs uninterruptible spin (no CDP) — we never observed a spinning-but-CDP-responsive state.4. Repro constraints and what we can share
The app is a large private codebase, so we still can't hand over source, but the failure is statistically quick under our automated soak (each incident lands inside/just after an initial-sync or view-open WebSocket burst; wall clock to first incident is usually < 5 min of driving). We can share privately if useful:
dotnet.native.js.symbols,.aotprofile,.cpuprofilefiles, and our headless-Chrome driver script (plain node + CDP, no framework),Happy to run instrumented/debug runtime bits against the same soak if you can point us at a build (e.g. assertions enabled or extra logging in
mono_aot_get_method_from_vt_slot/resolve_vcall).pavelsavara commentedon Aug 3, 2026
@benpetermorris with Fable on your team you could try to do the investigation yourself:
try to reproduce with latest Net11 preview 7 (due in few days), we keep fixing issues as we go.
Also turn on detailed logging
and read rest of https://github.com/dotnet/runtime/blob/main/docs/workflow/debugging/mono/wasm-debugging.md
Use binlog MCP to teach your agent to understand (and hack) our MSBuild. That will show you how to patch mono-aot.exe.
It may be interesting to try to reproduce the issue with Mono AOT for x64, that would allow you to use different set of debug tools.
It could also be memory corruption, both in runtime code or app code.
Feel free to ask questions :)
2 remaining items
benpetermorris commentedon Aug 4, 2026
@pavelsavara Thanks Pavel - ran your suggestions using Fable; here's the results. (Lots of mono runtime-specific code, plus a reference to what Fable thinks is another issue of the same class, so I'm hoping this is more intelligible to you than it is to me.)
Results below, mechanism first; the headline is that this is now a specific, twice-reproduced GC-rooting failure with named prior art, not an anonymous intermittent.
1. The assert is not a NULL class — it is the SGen GC-filler class
We had always read
class-accessors.c:90asg_assert (klass). At the runtime commit our bundle actually carries (SDK 10.0.302 → runtime pack10.0.9-servicing.26270.113, VMR901ca941, runtime5eaa18a9f3398d54ba9b8c0974d88171663be892), line 90 is a different branch ofmono_class_get_flags:So the object being virtually dispatched on has
vtable == array_fill_vtable— the vtablesgen_client_array_fill_rangestamps onto reclaimed nursery-fragment ranges ("Vtable of the objects used to fill out nursery fragments before a collection", sgen-mono.c). The reference the managed code dispatched through points at memory the collector considers free. This is your memory-corruption hypothesis, in a specific form: a live-in-code managed reference that was dead-to-the-GC (or not relocated) across a collection.The path is forced from there: a filler's vtable slots are never initialized, so any virtual call through a filler object lands in the lazy-slot path —
mini_llvmonly_init_vtable_slot → resolve_vcall → mono_aot_get_method_from_vt_slot, whose first statement isMONO_CLASS_IS_INTERFACE_INTERNAL (vtable->klass)→mono_class_get_flags→ the filler case asserts.resolve_vcallis the canary, not the culprit — which also explains why every historical capture of this bug looks identical at the top regardless of what the app was doing.2. The full stack, finally: 87 frames, symbolicated — the managed caller is named, twice
Error.stackTraceLimit = 1000(per your ask) plus-p:AotSymbols=truesymbolication. Two independent incidents (different sessions, independently published bundles) produced the identical failing stack. The dispatch that dies, top of the managed segment:The key type is our
TtrName— a sealed class overridingEquals/GetHashCode, noIEquatable<T>(henceObjectEqualityComparer), and freshly allocated per parse (never interned). The shape of the failing code matters:Metadata.Loaditself is AOT-compiled (llvmonly).fqnProp's only reference across the nested call lives in that AOT frame. A collection runs during the nested call (or at theAdd's own allocation); afterwards the reference dereferences as a nursery filler. So the concrete suspicion is a reference held in an llvmonly-AOT frame across a gsharedvt/interp-sandwiched call being missed (or not pinned/relocated) by SGen's root scan on wasm.Below that, the rest of the 87 frames are a textbook mixed-mode sandwich (the app is partial/profile-guided AOT, so hot methods are AOT and cold ones interpreted): four layers of
interp_entry → mono_interp_exec_method → do_jit_call → jiterpreter thunk → AOTtransitions withgsharedvt_in/out_sigwrappers at every boundary, bottoming out in aJSImportedsetTimeoutcallback (mono_wasm_invoke_jsexport → runtime_invoke → SynchronizationContext.Postcontinuation) that is pumping our client's inbound-message dispatch (WorkspaceClient.ProcessMessageAsync(KeyStoreUpdatedMessage) → KsChangeSet.Parse → … → Metadata.Load). Full symbolicated stack attached below.3. The assert fires ~1 ms after a collection — in both traced incidents
We now have two fully-traced incidents (
MONO_LOG_LEVEL=debug MONO_LOG_MASK=all), on independently published bundles, and in both the first assert lands ~1 ms after a collection:Incident 1 (mid-session, after ~100 s of inbound-burst traffic; trace has exactly 3
GC_MAJORin 34,366 lines):Incident 2 (0.8 s after opening the first app — the subscription burst — and here the trace narrates the kill in order):
Incident 2's sequence is the sharpest breadcrumb we have: a lazy class-init (the
EmptyArray<KeyValuePair<TtrName, MetadataValue>>cctor, i.e. the firstDictionary<TtrName,MetadataValue>machinery touch) runs inside the failingAdd, a nursery-full minor fires inside that init, and the key argument comes out of it pointing at a filler. So the reference that goes stale is (at minimum in this incident) an argument of gsharedvt-shared corlib code, live across a GC triggered under a runtime class-init/allocation helper called from llvmonly AOT code. Identical failing stack both times, down to the same wasm function indices.Given §1, the adjacency is mechanically necessary rather than coincidental: fillers are written into reclaimed nursery fragments at collection time, and a stale reference dereferences as a filler only in the window after the collection that reclaimed it (before the fragment is reused). Both flavors appear: a major's sweep (incident 1) and a minor's fragment refresh (incident 2).
Post-assert anatomy, which explains our two historical "wedge variants": the first assert exits the runtime (
.NET runtime already exited with 1); every later timer tick logs an "already exited" echo (our counters saw "5 asserts" — 1 real + 4 echoes); a mid-wedge CPU profile shows 99.9% idle. The DOM-silent-but-CDP-responsive "milder variant" is simply the post-mortem corpse of this assert. (Whether the CDP-dead, core-pinned hard variant — which under full AOT shows zero asserts — is the same defect wearing a spin instead of an assert is still open.)What we can not yet say is where the un-scanned/un-relocated reference copy lives — candidates being the gsharedvt in/out marshalling buffers, the interp↔AOT transition frames, or a receiver held only in wasm locals across a safepoint. That's where your local-runtime-build advice points next: we're standing up a Debug browser-wasm runtime + cross build on the Windows box (long paths now enabled; currently clearing the VS C++/cmake prerequisites) — the plan for it is
MONO_GC_DEBUGnursery clearing/canaries and instrumenting the root scan at the failing site, since the stack itself is no longer the unknown.3b. Prior art — this exact assert has a root-caused ancestor
Searching for the assert text: #63749 (2022, wasm AOT CI) and #104956 (2024, wasm CI) are the same
mono_class_get_flags: unexpected GC filler classassert; #104956 was closed pointing at #106200 "[browser][AOT] some assignments are not properly rooted", fixed by PR #106313 ("[mono][llvm] Fix alignment of local vars" —build_named_allocausingklass->min_align, i.e. GC-visible local storage at addresses the word-aligned scan can miss). That fix merged 2024-08 and is in our 10.0.9 bundle — and we still reproduce the filler dispatch, ingsharedvt-shared corlib frames, with the stranding GC triggered under lazy class-init. So the evidence reads as: the #106200 class of bug (AOT-held reference invisible to SGen's scan) has at least one more instance, somewhere in the gsharedvt/llvmonly argument or transition path.4. .NET 11 nightly status
On
11.0.100-rc.1.26402.102(runtimef7a6366c, VMR 2026-08-02) with the same app retargeted to net11.0 (bundle identity verified from the pack's own artifacts:bundle-runtime=11.0.0-rc.1.26402.102+322f5005…, exactly one runtime in the bundle):interp.c:2737—mono_error_assert_okaftermono_jit_compile_method_jit_only (mini_get_gsharedvt_out_sig_wrapper (sig)). This is a different defect from the filler bug: a missing gsharedvt out-sig wrapper in the AOT image (llvmonly cannot JIT one at runtime), i.e. partial-AOT image completeness, deterministic. The full 106-frame stack (attached) names the site: boot-timeDefaultWebAssemblyJSRuntimeconstruction →JSStreamReferenceJsonConverter.cctor→JsonEncodedText.Encode→ llvmonlyinit_method→JsonReaderHelper.cctor→SearchValues.Create(ReadOnlySpan<byte>)running interpreted →do_jit_call → init_jit_call_info→ missing wrapper → assert. (Our AOT profile was recorded against the net10 method set; on net11 the STJ/SearchValuesinternals changed, so the profile steers a different AOT subset and exposes the hole.)Consequence we want to flag honestly: on the nightly we cannot yet say whether the
class-accessors.c:90GC-rooting bug survives, because this boot-time wall sits in front of the burst window that triggers it. The interpreter control proves the app itself is fine on net11.5. Repro shape (for reduction)
The onset is always an inbound WebSocket burst being deserialized (System.Text.Json) and dispatched through the mixed AOT/interp sandwich on the main thread, with UI timers pumping. Incidence on 10.0.302 partial AOT in today's controlled runs: 2 incidents in 10 traced runs (
MONO_LOG_MASK=all) vs 1 in 3 untraced — plus a historical ~11-in-15 untraced figure measured before we hardened the instrument (treat that one as indicative only). Suggestive that full tracing suppresses the window without eliminating it; n is too small to quote a ratio. Two reduction data points so far: (a) one incident fired 0.8 s after opening the FIRST app (the subscription burst of a single master-detail view is enough — the rest of our scenario suite is unnecessary); (b) the stack says the renderer is not in the failing path — everything above the timer pump is message deserialization and metadata-dictionary population, so the slice to shrink toward is "wasm WorkspaceClient receiving a keystore-update burst," no DOM involved.On your x64 Mono AOT suggestion: given §1 we now suspect the un-scanned reference copy is wasm-specific (llvmonly + gsharedvt + wasm-locals territory); a desktop x64 AOT repro attempt would be diagnostic mostly in the negative. We're deprioritizing it in favor of the debug wasm runtime.
Full 87-frame symbolicated assert stack (SDK 10.0.302, partial AOT, incident 2026-08-03T16:10:04Z)
Full 106-frame symbolicated boot assert stack (.NET 11 nightly, partial AOT, interp.c:2737)
6. Debug-runtime session (local Debug runtime + Debug cross, built per your instructions)
We built the Debug browser-wasm runtime pack + Debug
mono-aot-crossat the nightly's runtime commit (f7a6366c) on Windows and swapped them into the publish via yourResolvedRuntimePackoverride (swap proven three ways: the override's own log line, the pack version in the bundle =11.0.0-dev, and a 66.6 MBdotnet.native.wasm). Posture: full AOT on net11 (partial is walled off by the §4 boot defect). Results:<disabled>:mono_class_get_flags: unexpected GC filler class— and it fired under FULL AOT, where we had never seen it (previously partial-AOT-only). The symbolicated stack is the IDENTICAL managed chain as both partial-AOT captures (`ObjectEqualityComparer.GetHashCode ← Dictionary.Add ← Metadata.Load ← … ← WebSocket-message dispatch on a timer continuation) — with zero interpreter frames: the whole chain is AOT'd. So the interp↔AOT sandwich is not an ingredient; the common factors narrow to llvmonly + gsharedvt-shared corlib frames + a collection during the nested deserialization. That is [browser][AOT] some assignments are not properly rooted #106200's bug class again.MONO_GC_DEBUG=clear-at-gcdoes not convert it (a stale nursery dispatch would have become a NULL-klass assert), and it reproduces with the jiterpreter fully disabled. So the hang is a control-flow trap in resolved code — likely a second defect, not the dangling reference wearing a different face.AOT NOT FOUND: System.Text.Json.Serialization.Metadata.JsonPropertyInfo1:IsDefaultValue (int)(looked up a handful of times per session; the last never returns). If that method's gsharedvt transition can loop rather than fail, that would match everything we see, including the original "uninterruptible call-free wasm loop" profile (the interpreter's dispatch loop body is one wasm function). Next on our side: a v8--prof` capture of a pinned hang against the Debug symbol map to name the spin PC exactly.Update — a fast repro recipe. With the Debug runtime pack and
MONO_GC_DEBUG=collect-before-allocs=5000,clear-at-gc, full-AOT reproduces at 5-in-6 runs within ~10 seconds of boot (3 hangs + 2 filler asserts in our leg; forced-collection lines verified in the trace). Both amplified filler asserts have the identical call-site stack. If it helps, we can run any diagnostic build you suggest against this recipe — incidents are now on demand rather than probabilistic.7. Offline artifact inspection: the compiler-emitted GC liveness is NOT the hole — every frame in the failing chain keeps the key conservatively scannable
Since the failing stack is now fully known and pure-AOT (§6.1), we checked the obvious codegen suspect offline: does the emitted code for the gsharedvt-shared frames keep the dictionary key GC-visible across the safepoint at the class-init/allocation call? We inspected the actual artifacts of the crashing Debug fullaot bundle at every stage — the
.dll.bcLLVM IR emitted by the (Debug)mono-aot-cross, the post--O2.owasm objects, and the final linked+wasm-opt'ddotnet.native.wasm, sliced at the exact function indices named in the captured assert stack (137818 =ObjectEqualityComparer<T_REF>.GetHashCode, 137709 =Dictionary<TKey_REF,TValue_REF>.TryInsert).Result — the
TARGET_WASMgc_pinmachinery (mini-llvm.c ~4035: per-frame[N x i32]alloca, every ref vreg volatile-stored into it after each write; ref args pinned in the entry block; conservative scan pins) is doing its job in all four frames:TryInsert: key volatile-stored togc_pin[0](frame+60 in the linked binary) and value togc_pin[1](frame+56) at entry, before theInitializecall — which is exactly where one traced incident's stranding GC ran (theEmptyArray<KeyValuePair<...>>cctor + nursery-full minor, §3 incident 2). Each slot is written exactly once in the whole function; the stores survive into the shipped binary.ObjectEqualityComparer<T_REF>.GetHashCode: receiver stored at frame+12/+8 on entry and again at frame+4 immediately before the vtable load, all before theinit_vtable_sloticall wrapper (the safepoint that asserts). Note this frame reads the filler vtable before that call — i.e., the reference was already stale on entry; the stranding happened under a caller.Dictionary.Add: both args volatile-pinned at entry.Metadata.Load) holding the key across the deep nested deserialization: the key is volatile-stored into a dedicated alloca at creation (TtrName.Parsereturn) and never overwritten within the loop iteration; the nested call's result is pinned on return; both are passed toAdd.So from the key's creation to the fatal dispatch there is no point where a conservative scan of the linear-memory stack could miss the object — it sits in 1–4 volatile stack slots across every safepoint, including the windows where the traced incidents place the stranding collection. Since the stores are
volatile, neither LLVM-O2nor binaryen removed them (verified in the final binary regardless).That moves the suspicion from codegen to the runtime side of the contract: either the conservative scan's coverage at the moment of the stranding collection (
sgen_client_scan_thread_data→sgen_conservatively_pin_objects_from (aligned_stack_start, stack_end)— is the emscripten data-stack range right for a GC entered synchronously under a class-init/alloc helper?), or pin/fragment accounting (a pinned nursery object's range nonetheless ending up inside a rebuilt fragment thatsgen_client_array_fill_rangefiller-stamps). We're happy to run either discrimination under the §6 amplifier recipe — e.g., logging the scanned range per collection and printing__stack_pointer+ frame addresses at the assert; incidents are on demand.8. Update — we ran that discrimination. Scan coverage is intact; the fault is downstream of the range check. And the zero-assert hang wedges inside a minor collection.
We instrumented our local Debug runtime (29 lines,
#ifdef HOST_WASM; patch available):sgen_client_scan_thread_datalogs each collection's conservatively scanned range[aligned_stack_start, stack_end]plus a scan-time SP probe and any skipped thread; theMONO_CLASS_GC_FILLERcase inmono_class_get_flagslogs an assert-time SP probe. One amplified leg (§6 recipe): 6 runs, 6 incidents — 4 filler asserts, 1 zero-assert hang, and 1 new third signature.(1) The filler bug is NOT a scan-coverage failure. In all four filler incidents the assert-time SP was inside the range the stranding collection (0–1 ms earlier) had scanned, e.g.:
assert_spwas byte-identical (0x158c490) across all four incidents (the invariant call chain again);stack_endwas constant across every scan of every run; no thread was ever skipped. Combined with §7 (the reference is volatile-stored in the scanned frames), the pipeline "slot value in scanned range → staged bysgen_conservatively_pin_objects_from→ pin queue → resolved to object start → excluded from fragments bysgen_build_nursery_fragments" demonstrably breaks somewhere AFTER the address-range check. From here the productive next step is pin-queue-level: trace one address (the gc_pin slot value) through staging,sgen_optimize_pin_queue,sgen_pin_objects_in_section, and the fragment walk in one amplified incident. If you can sketch the tracing you'd want, we can run it same-day — incidents are on demand.(2) First-ever NULL-klass sighting ties
clear-at-gcfragment zeroing to the same bug. One run asserted atclass-accessors.c:73, condition 'klass' not met— the plaing_assert (klass)this issue was originally (wrongly) assumed to be hitting. Underclear-at-gc,add_nursery_fragmemsets big fragments to 0 while only sub-SGEN_MAX_NURSERY_WASTEremainders get filler-stamped viasgen_clear_range— so NULL-vtable (:73) and filler-vtable (:90) are the same stale reference landing in the two fragment kinds. That's the conversion we predictedclear-at-gcwould produce for the hang and never saw; it shows up for the dispatch bug instead.(3) The zero-assert hang dies inside a collection. The hang's known last-breath sequence (STJ lookups → ~24 s silence → one
JsonPropertyInfo1:IsDefaultValuelookup) turns out not to be the end: ~42 s later a minor collection STARTS — our per-collection scan line prints once — and then nothing, ever (no precise-pass line, noGC_MINORsummary, tens of seconds to capture). Two independent hang tails stopped at the byte-identical stack depth (raw_start=0x158d448, scan_sp=0x158d364`). We considered and rejected the "console buffering" alternative: console events kept flowing for 100+ s while CDP commands were dead (renderer IO-thread transport doesn't need the wedged main thread), so a completed collection's remaining lines would have arrived. The wedge window is between the main thread's stack-scan entry and the precise pass — conservative pinning, pin staging/optimize, or the mark loop. A corrupted object graph spinning the mark loop would fit every observable (call-free, assert-free even on a Debug runtime, one pinned core, CDP-command-dead) and would make both §1's dispatch-on-reclaimed-memory and this hang downstream of one corruption — but that last step is inference, not yet measurement.pavelsavara commentedon Aug 4, 2026
@benpetermorris that's too dense for me too 😆
Questions: (possibly for Fable)
dotnet.withEnvironmentVariable("MONO_GC_PARAMS", "nursery-size=512m,soft-heap-limit=2g")in your main.js-sASSERTIONS=1viaEmccFlagsmsbuild propbenpetermorris commentedon Aug 4, 2026
@pavelsavara courtesy of Fable again - I asked it to be more concise this time :-)
PS it may have interpreted your question re new code paths / new classes or methods wrong - the project is some years old, but is new to WASM, and these instabilities have been present since day 1 of the port .. so I can't identify a specific change which provoked them.
Native libraries? None — pure managed. Scanned the full dependency closure: no
NativeFileReference, noDllImport/LibraryImport; JS interop is all source-generated[JSImport]/[JSExport]. Native side is the stock runtime pack + emscripten.Shrink the PGO/AOT set? Tried — profile-filter test, a small tool that drops METHOD records from the .aotprofile (reader hashes by id, sparse ids are legal). Four legs, 6 amplified runs each:
RuntimeError: function signature mismatch— a third bug, masking this one: interpreted code enters AOT'd gsharedvtList<T_REF>.Sort(IComparer<T_REF>)viado_jit_call+ out-sig wrapper on a thread-pool task, and an indirect call insideSorthits a wrong-signature target. Same boundary-completeness family as §4's net11 boot assert. Can file separately with the full symbolicated stack.Net: app-code AOT looks like an ingredient (2/6 → 0/6 at n=6; fits §2 — the victim's home frame
Metadata.Loadis app code), and the set can't shrink much below "everything" before the mismatch wall replaces the bug under study. Filter tool + profiles available.Victim / perpetrator classes? Victim: always a freshly allocated
TtrName(ordinary sealed class) being inserted as aDictionary<TtrName,·>key inMetadata.Load— a young object whose only live references are AOT-framegc_pinslots across a collection. Perpetrator: not an app class, and not LLVM codegen (§7: pin slots present and volatile in the shipped wasm; §8: scanned range covered the frames in 6/6 instrumented incidents). Surviving suspects are all inside SGen's pin pipeline: conservative-pin staging →sgen_optimize_pin_queue→sgen_pin_objects_in_section→sgen_build_nursery_fragmentsexclusion.Only after GC? Yes — every traced incident asserts 0–1 ms after a collection (major-sweep and minor flavors both), and §8's instrumented runs identify the stranding collection each time.
Delay GC with a big nursery? Ran it — GC-delay test,
nursery-size=512m,soft-heap-limit=2g, env verified live via banner + GC-line census. Baseline: 2-in-4 natural, 5/6 amplified.So the trigger is the collection itself, not heap pressure or occupancy — and the big nursery is a practical mitigation meanwhile.
Stale pointer to a moved object? Indistinguishable at the assert site — "moved and old copy's space reused" and "reclaimed in place" both leave the old address inside a filler-stamped fragment. What is pinned down: the address was inside the stranding collection's conservatively scanned range (6/6), and a conservatively scanned address must pin its object — which both prevents moving and excludes it from fragments. Whichever face it wore, the pin was lost.
emscripten
-sASSERTIONS=1? Ran it — assertions test:EmccEnableAssertions=true, fresh Release fullaot publish on the stock 10.0.9 runtime, amplified soak. Result: 3/6 incidents, all the identicalclass-accessors.c:90filler assert, zero emscripten-level faults (stack cookie / OOB / abort) before the SGen assert in any of them. Consistent with SGen bookkeeping corruption, not a native stack smash. (No zero-assert hang occurred in this leg, so ASSERTIONS-vs-hang is untested.) Side finding: the amplifier reproduces on the stock release runtime — ~2 min to incident, no local runtime build needed.New code path just before the crash? Yes, sharply: first-time generic instantiation / class-init under llvmonly, with a collection triggered inside the init helper, is where every incident of all three signatures lives. Best-traced incident: the stranding collection ran under the lazy cctor of
EmptyArray<KeyValuePair<TtrName,MetadataValue>>— the first-ever touch of that Dictionary instantiation, during first deserialization of our message graph. 2 of 3 mid-session incidents struck ~0.8 s after the first app-open (the burst that first instantiates those generics); the net11 boot assert (§4) and the zero-assert hang's final narration are likewise first-touch lazy init.What would help us most: a sketch of the pin-queue tracing you'd want — which prints across conservative-pin staging,
sgen_optimize_pin_queue,sgen_pin_objects_in_section, and thesgen_build_nursery_fragmentswalk, to follow one address through one collection. We have on-demand incidents (~10 s on the Debug pack; ~2 min on stock release), the Debug runtime + cross-compiler build loop on the repro box (~12 min incremental), and can run any diagnostic same-day.pavelsavara commentedon Aug 6, 2026
I improved some manifestations of
function signature mismatchPlease read and merge following PRs into your runtime branch and see if it improves your ability to bisect PGO/AOT set.
You can also make changes to your own build of runtime and AOT compiler to work around the issues.
Also feel free to file other AOT issues with good minimalistic repro and ping me on it.
benpetermorris commentedon Aug 11, 2026
@pavelsavara Tried your suggestions - no effect - and then had Claude run for 12 hours tracking down the issue mentioned here plus another one that only occurred in the .NET 11 preview. Both are fixed. PRs here:
mini_get_underlying_signatureis not a fixed point on wasm, so gsharedvt out-sig wrappers are emitted under a signature the runtime never asks for #132181 (Separate issue)[mono][wasm] get_wrapper_shared_vtype: make the two slot-type produce…
[mono][wasm] Pin ref OP_MOVE dests whose source can stop being rooted