Skip to content

Test failure: JIT/opt/FastTailCall/FastTailCallCandidates/FastTailCallCandidates.cmd #126820

Closed

Description

@VincentBu

Failed in: runtime-coreclr r2r 20260411.1

Failed tests:

R2R-CG2 windows x64 Checked no_tiered_compilation @ Windows.10.Amd64.Open
- JIT/opt/FastTailCall/FastTailCallCandidates/FastTailCallCandidates.cmd

Error message:


Return code:      1
Raw output file:      C:hwA9780930wA2DD0912uploadsFastTailCallFastTailCallCandidatesoutput.txt
Raw output:
BEGIN EXECUTION
FastTailCallCandidates.dll
        1 file(s) copied.
 6:46:45.85
Response file: C:hwA9780930wA2DD0912eJIToptFastTailCallFastTailCallCandidatesFastTailCallCandidates.dll.rsp
C:hwA9780930wA2DD0912eJIToptFastTailCallFastTailCallCandidatesIL-CG2FastTailCallCandidates.dll
-O
-o:C:hwA9780930wA2DD0912eJIToptFastTailCallFastTailCallCandidatesFastTailCallCandidates.dll
--targetarch:x64
--targetos:windows
--verify-type-and-field-layout
--method-layout:random
-r:C:hwA9780930pSystem.*.dll
-r:C:hwA9780930pMicrosoft.*.dll
-r:C:hwA9780930p\xunit.*.dll
-r:C:hwA9780930pmscorlib.dll
-r:C:hwA9780930p
etstandard.dll
"Running CrossGen2:  "C:hwA9780930pcrossgen2crossgen2.exe" @"C:hwA9780930wA2DD0912eJIToptFastTailCallFastTailCallCandidatesFastTailCallCandidates.dll.rsp"   -r:C:hwA9780930wA2DD0912eJIToptJIT.optIL-CG2*.dll  -r:C:hwA9780930wA2DD0912eJIToptFastTailCallFastTailCallCandidatesIL-CG2*.dll"
 6:46:49.12
Crossgen2 failed with exitcode - -1073741819
Test Harness Exitcode is : 1
To run the test:
Set up CORE_ROOT and run.
> C:hwA9780930wA2DD0912eJIToptJIT.opt../FastTailCall/FastTailCallCandidates/FastTailCallCandidates.cmd

Stack trace:

   at Xunit.Assert.True(Nullable`1 condition, String userMessage) in /_/src/arcade/src/Microsoft.DotNet.XUnitAssert/src/BooleanAsserts.cs:line 135
   at TestLibrary.OutOfProcessTest.RunOutOfProcessTest(String assemblyPath, String testPathPrefix)
   at Program.<<Main>$>g__TestExecutor329|0_330(StreamWriter tempLogSw, StreamWriter statsCsvSw, <>c__DisplayClass0_0&)

Activity

  1. added
    area-CodeGen-coreclr
    blocking-clean-ci-optional
    on Apr 13, 2026
  2. added
    untriaged
    on Apr 13, 2026
  3. dotnet-policy-service commented on Apr 13, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
    See info in area-owners.md if you want to be subscribed.

  4. MihuBot commented on Apr 13, 2026

    @MihuBot

    I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):

  5. added this to the 11.0.0 milestone on Apr 13, 2026
  6. removed
    untriaged
    on Apr 13, 2026
  7. mangod9 commented on Apr 13, 2026

    @mangod9
    Member

    dump analysis:

    CrossGen2 (NativeAOT) AV at SVR::GCHeap::Promote dereferencing
    ppObject=NULL during Server GC gen1 mark phase in R2R pipeline build 1375591
    (April 12, 2026).
    
    ----------------------------------------------------------------------------
    
    From the dump (crossgen2.exe.3132.dmp, Windows x64):
    
    Symbolized crash stack:
    
     crossgen2!SVR::GCHeap::Promote(ppObject=NULL) ← AV reading address 0
     crossgen2!TGcInfoDecoder::EnumerateLiveSlots+0x1238
     crossgen2!CoffNativeCodeManager::EnumGcRefs(isActiveStackFrame=true)
     crossgen2!Thread::GcScanRootsWorker(thread=0x241`06e270f0)
     crossgen2!SVR::gc_heap::mark_phase(condemned_gen=1)
    
    The GC scans a suspended thread. The GcInfoDecoder, scanning the active frame
    with reportScratchSlots=true, reports volatile register rdx as a live GC
    slot. GetRegisterSlot() returns pRegisterSet->pRdx — but pRdx is NULL →
    Promote(NULL) → AV.
    
    The scanned thread's state:
    
    REGDISPLAY for the frame being scanned:
    
     - IP = 0x7ff68e571c3d →
    InstantiatedType.<GetVirtualMethods>d__24.MoveNext+0x7d
     - pRdx = NULL, pR8 = NULL, pR9 = NULL — volatile register save locations
    unpopulated
     - Callee-saved registers (pRbx, pRsi, pRdi, etc.) are properly populated
    
    The scanned thread's native stack shows
    ReturnFromUniversalTransitionReturnResult as a return address, confirming the
    thread was in an interface dispatch slow path. The code at the crash IP:
    
     mov  rdx, [rcx+18h]          ; rdx = enumerator from state machine field
     mov  rcx, rdx                ; rcx = this (for IEnumerator.MoveNext)
     call RhpResolveInterfaceMethodFast  ; resolve interface vtable
     → IP  mov  rcx, rdx          ; ← thread was hijacked here, rdx is a live GC 
    ref
    
    ----------------------------------------------------------------------------
    
    Prior fix (PR #126328, merged March 31):
    
    PR #126328 added UnwindVolatileArgRegisters() to
    UnwindUniversalTransitionThunk() at StackFrameIterator.cpp:1629. This
    populates pRcx, pRdx, pR8, pR9 from the UniversalTransitionStackFrame's saved
    m_intArgRegs[]. The fix is confirmed present in build 1375591.
    
    Why the fix didn't prevent this crash:
    
    PR #126328 fixed the case where the thread is voluntarily suspended inside 
    RhpUniversalTransition — the UnwindUniversalTransitionThunk path correctly
    populates volatile registers from the thunk's saved copies.
    
    But this crash takes a different path: the thread was hijacked by the GC via
    RhpGcProbeHijack. When a thread is hijacked at a return address, the hijack
    stub creates a PInvokeTransitionFrame and the
    StackFrameIterator::InternalInit reads register save locations from it based
    on the PTFF_SAVE_Rxx flags (lines 328-335 of StackFrameIterator.cpp).
    
    The hijack stub at GcProbe.asm:109 creates the frame with:
    
     mov  r8d, DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_RAX + PTFF_SAVE_RCX + 
    PTFF_THREAD_HIJACK
    
    This saves only RAX and RCX — PTFF_SAVE_RDX is NOT included. When
    InternalInit processes this frame, pFrame->m_Flags & PTFF_SAVE_RDX is false,
    so pRdx stays NULL. The iterator then calls EnsureInitializedToManagedFrame()
    which unwinds through the UniversalTransition thunk, but
    UnwindVolatileArgRegisters() overwrites pRcx/pRdx/pR8/pR9 with pointers into
    the thunk's m_intArgRegs[]. However, by this time the hijack has already
    stomped the return address and register state — the thunk's saved
    m_intArgRegs may not contain the correct values that the managed caller frame
    expects.
    
    The fundamental issue: the hijack path and the UniversalTransition path
    compete to populate the volatile register save locations, and the hijack path
    doesn't save enough registers. When the managed caller frame above is scanned
    as the active frame, its GC info reports rdx as live, but rdx's save location
    was never properly recorded.
    
    ----------------------------------------------------------------------------
    
    Root cause: RhpGcProbeHijack doesn't save all volatile argument registers
    
    The hijack stub saves only RAX and RCX in the transition frame. The comment
    in AsmMacros.inc:361 says:
    
     PTFF_SAVE_RCX equ 00000200h  ;; RCX is saved in hijack handler - in case it
    contains a GC ref
    
    But RDX can also contain a GC reference at call return sites. The GC info for
    the caller frame marks rdx as live, but the hijack frame doesn't preserve it.
    
    Affected code:
    
     - src/coreclr/nativeaot/Runtime/amd64/GcProbe.asm:109 — Windows AMD64 hijack
     - src/coreclr/nativeaot/Runtime/amd64/GcProbe.S:127 — Unix AMD64 hijack
     - Equivalent ARM64 hijack stubs may have the same gap for volatile argument
    registers
    
    Proposed fix:
    
     1. Save all volatile argument registers in the hijack frame. Update
    RhpGcProbeHijack to include RDX, R8, R9 in the transition frame flags and
    save their values:
    
     ;; GcProbe.asm line 109 - Before:
     mov  r8d, DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_RAX + PTFF_SAVE_RCX + 
    PTFF_THREAD_HIJACK
    
     ;; After:
     mov  r8d, DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_RAX + PTFF_SAVE_RCX + 
    PTFF_SAVE_RDX + PTFF_SAVE_R8 + PTFF_SAVE_R9 + PTFF_THREAD_HIJACK
    
    The PUSH_PROBE_FRAME macro must also be updated to save RDX, R8, and R9 into
    the transition frame's m_PreservedRegs when the corresponding flags are set.
    
     1. Same fix for GcProbe.S (Unix AMD64, line 127) — add PTFF_SAVE_RDX + 
    PTFF_SAVE_R8 + PTFF_SAVE_R9.
     2. Audit ARM64 hijack stubs for the same pattern — check if volatile
    argument registers (X0-X7 beyond what's currently saved) need to be included.
    
    This ensures that when the GC hijacks a thread and the GC info for the
    managed frame at the hijack point reports volatile registers as live, those
    registers have valid save locations in the transition frame.
    

    @MichalStrehovsky @jkotas

  8. locked and limited conversation to collaborators on May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-CodeGen-coreclrblocking-clean-ci-optional

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions