Repository navigation
Description
Description
A native x64 Windows process that hosts .NET 10 in-process fail-fasts on the finalizer thread a few seconds after start. The finalizer is collecting a DynamicMethod whose first JIT attempt was discarded after a jump stub overflow. The discarded attempt's code block is still on the resolver's list of recorded code pointers, but its CodeHeader in executable memory was never written, so UnwindInfoTable::UnpublishUnwindInfoForMethod reads a null real code header.
We have four full dumps from one end-user machine (.NET 10.0.10, coreclr.dll 10.0.1026.32716, commit f7d90799ce4ef09a0bb257852a57248d2a8fb8dd). All four show the same stack, 7 to 9 seconds after process start:
coreclr!CodeHeader::GetNumberOfUnwindInfos (inline) read of address 0x20
coreclr!UnwindInfoTable::UnpublishUnwindInfoForMethod+0x52
coreclr!LCGMethodResolver::TryDestroyCodeHeapMemory (inline)
coreclr!DynamicMethodDesc::TryDestroy+0xb2
coreclr!RuntimeMethodHandle_Destroy+0x17e
System_Private_CoreLib!System.Reflection.Emit.DynamicResolver+DestroyScout.Finalize+0x5a
System_Private_CoreLib!System.GC.RunFinalizers+0x8c
coreclr!FinalizerThread::FinalizeAllObjects+0x55
The vectored exception handler escalates the access violation through EEPolicy::HandleFatalError, and the process fail-fasts.
What the dumps show:
- In all four dumps, the method being destroyed is
InvokeStub_EventSourceAttribute.set_Name. - In one dump, the resolver's
m_initialCodePointer.m_pEntryis0x28f60040. The 8 bytes before it (theCodeHeader) are zero, and so are the code bytes. - The retry's block, which holds the real stub code, was unpublished and freed by the same loop just before the crash.
ExecutableAllocator::g_isWXorXEnabledands_publishingActiveare both true.
The sequence, from the source (10.0.11 through 10.0.13, 11.0 RC2, and main are the same on this path):
coreclr.dllwas mapped below 4 GB (see Other information), so the first JIT attempt of the method, made withg_fAllowRel32 == TRUE, overflowed rel32.JumpStubOverflowCheckdetected it,ResetForJitRetryran, and the method was compiled again.EECodeGenManager::allocCodehad already recorded the first block throughLCGMethodResolver::AllocateRecordCodePointer. With W^X, the real code header pointer was written only to the RW buffer (pCodeHdrRW->SetRealCodeHeader(...)), andResetForJitRetryfrees that buffer.WriteCodeBytesnever ran for the attempt, so theCodeHeaderin executable memory stays zero.- The retry allocated and recorded a second block, which became the list head.
- When the
DynamicMethodis collected,TryDestroyCodeHeapMemorywalksm_DynamicCodePointersand callsUnpublishUnwindInfoForMethodfor each entry. The retry's block is handled correctly. For the first block,GetCodeHeaderFromStartAddressreturns the zeroed header, andpHeader->GetNumberOfUnwindInfos()dereferences null.
Reproduction Steps
We do not have a standalone repro. The crash needs all of the following:
- Windows x64 with W^X enabled, which is the default.
- A JIT target more than 2 GB from the code heap, so the first rel32 attempt overflows.
- The first overflow in the process has to land on a
DynamicMethod, becauseg_fAllowRel32is cleared after the first overflow. - The
DynamicMethodhas to be collected.
An untested suggestion for a runtime build: on a Debug or Checked runtime, DOTNET_ForceRelocs=1 sets _fForceJumpStubOverflow in JumpStubOverflowCheck, which should make the first attempt of every method overflow. Creating, invoking, and dropping a DynamicMethod, then forcing a GC and waiting for pending finalizers, should then reach the same code path.
Expected behavior
Collecting a DynamicMethod does not crash, whether or not one of its JIT attempts was discarded.
Actual behavior
An access violation reading address 0x20 in UnwindInfoTable::UnpublishUnwindInfoForMethod on the finalizer thread, followed by a fail-fast.
Regression?
Probably, compared with .NET 9. In 9.0.21, UnpublishUnwindInfoForMethod returns early unless s_publishingActive is set, and only UnwindInfoTable::PublishUnwindInfo sets it, from the ETW path. #116354 calls UnwindInfoTable::Initialize() at startup, so .NET 10 publishes unwind info in every process on Windows x64. In 11.0, UnpublishUnwindInfoForMethod no longer checks s_publishingActive at all.
Known Workarounds
Neither has been verified:
DOTNET_JitEnableOptionalRelocs=0stops the rel32 first attempt, so no attempt gets discarded.DOTNET_EnableWriteXorExecute=0writes the header straight into the code block, so a discarded block should not have a null header. This turns off a security mitigation.
Configuration
- .NET 10.0.10 (Microsoft.NETCore.App 10.0.10,
coreclr.dll10.0.1026.32716). The code on this path is unchanged in 10.0.13, 11.0 RC2, and main as of 2026-10-15. - Windows 10 22H2 (build 19045), x64.
- A native x64 C++ application (the JAWS screen reader) that loads .NET in-process through ijwhost and comhost.
Other information
Why coreclr.dll loaded below 4 GB on this machine: in each dump, a 64 KB Detours trampoline region sits in the free range where coreclr.dll would normally load, between hostpolicy.dll and clrjit.dll. That range is exactly the size of the images that ended up below 4 GB: coreclr.dll and System.Private.CoreLib.dll in three dumps, and coreclr.dll alone in the fourth. Detours first looks for free memory 1 GB below the function it hooks. The regions belong to a localization DLL in our application, which hooks user32!LoadMenuW and KernelBase resource functions at startup, and to an antivirus hook DLL. The loader then mapped coreclr.dll at bases between 0x10190000 and 0x10c20000. On another boot, the same machine loaded coreclr.dll at its usual high address and ran for 2.5 hours without this crash. Any in-process hooking that reserves memory in the DLL range before the runtime loads can trigger this, so other native hosts are probably exposed too.
Possible fixes: clear the recorded code pointer of a discarded attempt in the retry path (TryDestroyCodeHeapMemory already skips null entries), or have UnpublishUnwindInfoForMethod skip a block whose real code header is null.
The dumps come from a customer and contain user data, so we cannot attach them, but we can answer questions about their contents.
Activity
dotnet-policy-service commentedon Oct 15, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.