Repository navigation
Description
I couldn't analyze that dump - but it could be an environment issue (this is a linux arm64 dump, I have x64 - I tried windows and linux and both failed to load SOS). I also noticed that the build analysis infra that's supposed to auto-analyze and dump to log wasn't working cc @hoyosjs
Build Information
Build: https://dev.azure.com/dnceng-public/cbb18261-c48f-4abb-8651-8cdcb5474649/_build/results?buildId=1445922
Build error leg or test failing: System.Private.Xml.Tests.WorkItemExecution
Pull request: #128864
Error Message
DO NOT USE JSON BELOW IF THIS IS A BUILD BREAK otherwise build analysis will allow pull requests to merge that break the build worse. For a build break, do not use this issue form. Make a regular new issue.
Fill the error message using step by step known issues guidance.
{
"ErrorMessage": ["xunit.console.dll System.Private.Xml.Tests.dll", "exit code 139"],
"ErrorPattern": "",
"BuildRetry": false,
"ExcludeConsoleLog": false
}Known issue validation
Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1445922
Error message validated: [xunit.console.dll System.Private.Xml.Tests.dll exit code 139]
Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 6/3/2026 4:06:49 PM UTC
Report
💡 View the full list of hits in the Build Insights portal
Summary
| 24-Hour Hit Count | 7-Day Hit Count | 1-Month Count |
|---|---|---|
| 0 | 0 | 0 |
Activity
dotnet-policy-service commentedon Jun 3, 2026
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.
mangod9 commentedon Jun 3, 2026
Issue #128953 — System.Private.Xml.Tests SIGSEGV (Mono MiniJIT, Linux ARM64)
Summary
SIGSEGV (exit code 139) in System.Private.Xml.Tests on Linux ARM64 Mono MiniJIT (Debug build). The crash occurs in JIT-compiled code that attempts to execute a safepoint poll through a thunk pointing to unmapped memory. The crash reporter itself then crashes in
_Unwind_Backtrace, making the core dump harder to analyze.Environment
build_linux_arm64_debug_mono_minijit_librariestestsDump Analysis
Core dump source
/tmp/dump-128953/core.1000.17— ELF 64-bit ARM64 Linux core file (209MB)The Double-Crash Problem
The core dump captures a secondary crash, not the original one:
_Unwind_Backtraceinlibgcc_s.so.10xf300ffbd12a0(unmapped)The original SIGSEGV triggers Mono's crash handler (
mono_sigsegv_signal_handler_debug→mono_handle_native_crash→mono_dump_native_crash_info), which callsbacktrace()→_Unwind_Backtrace, and_Unwind_Backtraceitself crashes (with x24=0x26, an invalid pointer).Original Crash — Saved Signal Context
From the
ucontext_ton the signal handler's stack at0xf2fff6ffb980:PC = fault_address = x16: The crash was an indirect branch (
br x16) to unmapped memory.The Crashing Thunk
At LR
0xf30010cd0374, the calling instruction at0xf30010cd0370isbl 0xf30010cd1474— a branch to a thunk:Safepoint Poll Pattern
The JIT code at the crash site implements a GC safepoint poll:
This pattern is emitted by
OP_GC_SAFE_POINTinmini-arm64.c:5931-5940viaemit_call(MONO_JIT_ICALL_mono_threads_state_poll).Thunk Table Analysis
The method's thunk area shows multiple thunks, some valid, some corrupted:
0xf30010cd14440xf3001afe6c900xf30010cd14540xf3001afe6c900xf30010cd14640xf300ffbd12a00xf30010cd14740xf300ffbd12a00xf30010cd14840xf300ffbd12a00xf30010cd1494+0x0000000000000000Key observations:
0xf3001afe6c900xf300ffbd12a0(3 different thunks, same bad target)mono_threads_state_pollshould be at0xf3001b3109a8— neither address matchesPre-Signal Stack Trace
The stack above the signal frame shows the trampoline resolution chain that ran on this thread:
This means the thunk was being patched (or had just been patched) by the trampoline resolution mechanism when the crash occurred.
Root Cause Analysis
How Thunks Work (ARM64)
ARM64
blinstructions can only reach ±128MB. When a call target is farther, the JIT creates a thunk in a reserved area adjacent to the method's code:Lifecycle:
emit_callrecords aMONO_PATCH_INFO_JIT_ICALL_IDpatch withMONO_R_ARM64_BLrelocationmono_resolve_patch_targetresolves the icall → returns a lazy trampoline address (viamono_icall_get_wrapper)arm_patch_full(cfg, ...)creates a thunk pointing to the lazy trampolinemono_magic_trampoline→common_call_trampolinecompiles the icall wrapper →mono_arch_patch_callsite→arm_patch_full(NULL, ...)→create_thunk(NULL, ...)rewrites the thunk with the compiled wrapper's addressWhat Went Wrong
The thunk target
0xf300ffbd12a0was patched by step 4 (confirmed by the trampoline resolution chain on the stack). This address is unmapped — it's ~3.8GB away from any mapped region in the process, consistent with a freedmmapallocation (a JIT code buffer that wasmunmap'd).Primary Hypothesis: Stale Resolved Address from Freed Code Manager
mono_jit_free_method(mini-runtime.c:2986) frees dynamic method code but does NOT invalidate thunks in other methods.System.Private.Xmlheavily uses dynamic code generation (AssemblyBuilder/TypeBuilder/ILGeneratorinCodeGenerator.cs:1284) for XML serialization. When a dynamic method is GC-collected:mono_jit_free_method→mono_code_manager_destroy(ji->code_mp)(line 3083) →munmapof the code bufferjump_target_hashcleanup (lines 3042-3057) only removes entries pointing INTO the freed code — it does not scan all methods' thunk tables for thunks targeting the freed addressThe critical gap: there is zero code in Mono to invalidate thunks that were patched to point to a freed method's address. Verified by searching for
thunk_invalidat,free_thunk,thunk_free,invalidate_thunkacross the entiremono/mini/directory — no results.The
MONO_ARCH_HAVE_INVALIDATE_METHODpath (line 3060) only handles the special case of delegate wrappers withkeep_delegatesdebug option.Why the Safepoint Poll Is Affected
The safepoint poll calls
mono_threads_state_pollthrough a JIT icall wrapper. The wrapper itself should be in a permanent code manager. However, the trampoline resolution flow incommon_call_trampoline(line 628) callsmono_jit_compile_method(m, error)which may in some edge cases compile code into a collectiblejit_mmcontext — this is exactly the class of bug fixed by PR #125583 (jit_mmmismatch in delegate trampolines for dynamic methods).The address pattern strongly suggests a freed code buffer:
0xf300ffbd12a0— the bad target0xf3001b3109a8— expectedmono_threads_state_polladdress0xf3001afe6c90— lazy resolver trampoline (still valid)0xf300high bytes (same virtual address space region) but the lower bits differ wildly — consistent with a differentmmap'd allocation in the same ASLR regionSupporting Evidence
jit_mmmismatch inmono_create_delegate_trampoline_infofor dynamic methods — proves this class of bug exists in the trampoline infrastructureAlternative Hypotheses
Race condition in
emit_thunk: Whilecreate_thunkholdsjit_mm_lock, the 8-byte target write at*(guint64*)code = targetis atomic on ARM64 (aligned 64-bit store). However, there's no memory barrier between the store and icache flush — another CPU could read the old value. This is unlikely to produce an UNMAPPED address (old value would be the trampoline, which is valid).Memory corruption: A wild write corrupting the thunk's literal pool. Less likely because exactly 3 thunks have the same consistent bad value.
Code manager reuse: The freed code buffer's virtual address was reused by another
mmapfor different code, which was then also freed. This would explain why the address is completely unmapped.mangod9 commentedon Jun 3, 2026
Update: Root Cause Identified — Cross-Cache-Line Torn 64-bit Access
Further investigation of the thunk alignment reveals the root cause of the +4GB corruption.
The Alignment Problem
All thunk literals in this method are 4-byte aligned but NOT 8-byte aligned. This is because the thunk area starts at
code + code_size + unwindlen(mini.c:2146-2147), andcode_size + unwindlenis not guaranteed to be a multiple of 8:Cache Line Crossing
The crashing thunk T5's literal is at address
0xf30010cd147c:The 8-byte literal spans two cache lines:
...1440-...147f): contains low 32 bits (0xffbd12a0)...1480-...14bf): contains high 32 bits (0x0000f2ff)Per ARM ARM (B2.2.1), a 64-bit access not naturally aligned to 8 bytes is not guaranteed single-copy atomic. When crossing a cache line boundary, the hardware performs two independent operations.
The Torn Read
During runtime thunk patching (
emit_thunkatmini-arm64.c:1272),*(guint64*)(code + 8) = (guint64)targetwrites0xf2ffffbd12a0across two cache lines. A concurrent thread executingldr x16, [pc+8]observes:0xffbd12a00x0000f3000xf3001afe6c90)0xf300ffbd12a0Every 4th thunk in this method has its literal at cache line position 60, making it vulnerable. The bug is rare because it requires concurrent execution during the first-time trampoline resolution.
Proposed Fix
Align the thunk area start to 8 bytes in
mini.c:The reservation size should also account for the padding:
Additionally, a defensive assertion in
emit_thunk:dotnet-policy-service commentedon Jun 4, 2026
Tagging subscribers to this area: @dotnet/area-system-xml
See info in area-owners.md if you want to be subscribed.
jeffschwMSFT commentedon Aug 24, 2026
removing blocking-clean-ci as it has not failed in 30 days
24-Hour Hit Count 7-Day Hit Count 1-Month Count
0 0 0