Skip to content

[ci-scan] Test failure: NumberHandlingTests_Metadata.Number_AsCollectionElement_RoundTrip on NativeAOT windows-x64 #129010

Closed

Description

@github-actions

Build Information

Build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1448568
Build error leg or test failing: windows-x64 Release NativeAOT_Checked_Libs_SpeedOpt - System.Text.Json.SourceGeneration.Roslyn4.4.Tests

Error Details

[FAIL] System.Text.Json.SourceGeneration.Tests.NumberHandlingTests_Metadata.Number_AsCollectionElement_RoundTrip
Assert.Throws() Failure: Exception type was not an exact match
Expected: typeof(System.Text.Json.JsonException)
Actual:   typeof(System.NullReferenceException)
   at System.Text.Json.Serialization.Tests.NumberHandlingTests.Number_AsCollectionElement_RoundTrip() in /_/src/libraries/System.Text.Json/tests/Common/NumberHandlingTests.cs:line 388
   at System.Text.Json.Serialization.Tests.NumberHandlingTests.Number_AsCollectionElement_RoundTrip()

Error Message

true only for clear infra flakes. ExcludeConsoleLog skips helix log scanning. -->

{
  "ErrorMessage": ["NumberHandlingTests_Metadata.Number_AsCollectionElement_RoundTrip", "Expected: typeof(System.Text.Json.JsonException)"],
  "ErrorPattern": "",
  "BuildRetry": false,
  "ExcludeConsoleLog": false
}

Impact on platforms

  • runtime-nativeaot-outerloop (def 265) / windows-x64 Release NativeAOT_Checked_Libs_SpeedOpt / System.Text.Json.SourceGeneration.Roslyn4.4.Tests / Exit code 1
  • Occurrences in window: 2 builds (1448568, 1449365)

First build it occurred

Additional context

Under NativeAOT, the test expects JsonException when deserializing a number as a collection element, but receives NullReferenceException instead — suggesting the NativeAOT compiled code path throws an unexpected null dereference before the expected validation logic fires.

Related: #66220 (same test, different platform — iOS/Mono, filed 2022, still open)


Filed by ci-failure-scan (detection only). ci-failure-fix walks open [ci-scan] KBEs and either opens a small fix PR or comments here to loop in owners — it never disables the test.

Generated by CI Outer-Loop Failure Scanner · ● 29.6M · ◷

Report

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
0 0 0

Activity

  1. dotnet-policy-service commented on Jun 5, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
    See info in area-owners.md if you want to be subscribed.

  2. jeffschwMSFT commented on Jun 5, 2026

    @jeffschwMSFT
    Member

    closing as has not failed since opening

  3. MichalStrehovsky commented on Jun 8, 2026

    @MichalStrehovsky
    Member

    Looks to be runtime-async-adjacent.

    @jakobbotsch was #128706 x86-only or could it affect x64 too?

  4. jakobbotsch commented on Jun 8, 2026

    @jakobbotsch
    Member

    Looks to be runtime-async-adjacent.

    @jakobbotsch was #128706 x86-only or could it affect x64 too?

    It should be x86 only. I did a quick audit and I didn't immediately see anything that would affect other platforms.

  5. 4 remaining items

  6. added this to the 11.0.0 milestone on Jun 10, 2026
  7. self-assigned this
    on Jun 11, 2026
  8. jakobbotsch commented on Jun 11, 2026

    @jakobbotsch
    Member

    If you still have the setup locally, can you see if reverting #127932 fixes it?

  9. MichalStrehovsky commented on Jun 11, 2026

    @MichalStrehovsky
    Member

    Still fails with a revert of that. My steps:

    git revert b540c365da5e5f71a6c0389f5764f363bc59d4a2  
    rmdir /s /q artifacts  
    build.cmd clr.aot+libs -c Release 
    dotnet.cmd build src\libraries\System.Text.Json\tests\System.Text.Json.SourceGeneration.Tests\System.Text.Json.SourceGeneration.Roslyn4.4.Tests.csproj /p:TestNativeAot=true -c Release -f net11.0
    run_tests.bat 
    

    Where run_tests.bat is:

    @echo off
    setlocal enabledelayedexpansion
    
    set EXE=D:\git\runtime1\artifacts\bin\System.Text.Json.SourceGeneration.Roslyn4.4.Tests\Release\net11.0\publish\System.Text.Json.SourceGeneration.Roslyn4.4.Tests.exe
    
    for /L %%i in (1,1,100) do (
        echo === Run %%i of 100 ===
        "%EXE%" -notrait category=failing
        if !errorlevel! neq 0 (
            echo.
            echo FAILED on run %%i with exit code !errorlevel!
            exit /b !errorlevel!
        )
    )
    
    echo.
    echo All 100 runs completed successfully.
    exit /b 0
    
    
  10. jakobbotsch commented on Jun 12, 2026

    @jakobbotsch
    Member

    I've looked at a couple of crashes under debugger. Both of them were with functions related to PerformAsCollectionElementSerialization. This function does a lot of GVM lookups that result in runtime async methods, I am not sure if related or a red herring.
    A few notes:

    • In both cases the continuation is null, so we haven't suspended/resumed, i.e. we are executing this function synchronously
    • In one case an object reference was corrupted with what looked to be string data. The value ended with 0xc, so not even a "forgotten" object reference due to a GC hole.
    • For both cases I saw the register r15 seemingly being incorrect inside PerformAsCollectionElementSerialization. In the one case it had string data, in the other case it does not point to the closure allocated by the method as expected (instead it has some other value with a wrong method table)

    I wonder if some miscompile ends up corrupting r15 on a rare path, or if some rare GVM lookup can result in r15 not being restored. Does the GVM lookup ever end up calling into any assembly helpers @MichalStrehovsky?

  11. MichalStrehovsky commented on Jun 15, 2026

    @MichalStrehovsky
    Member

    I wonder if some miscompile ends up corrupting r15 on a rare path, or if some rare GVM lookup can result in r15 not being restored. Does the GVM lookup ever end up calling into any assembly helpers @MichalStrehovsky?

    I double checked in a debugger, but there should be no special assembly helpers in this path. GVM calls only have this shape:

    00007FF6046E8EF0  lea         rdx,[__RuntimeMethodHandle_repro_IBot__Blah<Object> (07FF604746A20h)]  
    00007FF6046E8EF7  call        S_P_CoreLib_System_Runtime_TypeLoaderExports__GVMLookupForSlot (07FF6046B8460h)  
    00007FF6046E8EFC  test        al,2  
    00007FF6046E8EFE  je          repro_Program___Main__+2Eh (07FF6046E8F0Eh)  
    00007FF6046E8F00  mov         rdx,qword ptr [rax+6]  
    00007FF6046E8F04  mov         rcx,rbx  
    00007FF6046E8F07  cmp         dword ptr [rcx],ecx  
    00007FF6046E8F09  call        qword ptr [rax-2]  
    00007FF6046E8F0C  jmp         repro_Program___Main__+35h (07FF6046E8F15h)  
    00007FF6046E8F0E  mov         rcx,rbx  
    00007FF6046E8F11  cmp         dword ptr [rcx],ecx  
    00007FF6046E8F13  call        rax 
    

    and GVMLookupForSlot is "normal" C# and the target of the indirect call is the resolved method (possibly an unboxing thunk in assembly if the GVM is implemented on a struct, but those are simple).

  12. jakobbotsch commented on Jun 16, 2026

    @jakobbotsch
    Member

    I managed to get a TTD trace after running a bunch of these in parallel overnight.
    From the trace it looks like an issue in handling GC during EH. One thread is running the test that calls PerformAsCollectionElementSerialization, and that thread is deep inside a child frame executed via a funclet. GC happens on a different thread and the GC stack walk for the test ends up skipping over ~20 managed frames.
    We are unwinding over an InThrowSiteThunk that calls into HandleExCollided when we end up skipping over the frames.
    The end result is that when the scanning sees r15 is live in PerformAsCollectionElementSerialization it does not relocate the correct r15 that was saved in one of the skipped frames.

    @janvorli Can you please take a look?
    My analysis and the trace is available at https://1drv.ms/u/c/2cb5a68f37fcb996/IQBaHvpmXzznSoOiiwPp4E-PAT8DPfLQltorhoW1Edblu4c?e=59bafV.

  13. added a commit that references this issue on Jun 20, 2026
    e556d5a
  14. added a commit that references this issue on Jul 15, 2026
    bc9bf73
  15. locked and limited conversation to collaborators on Jul 21, 2026
  16. added a commit that references this issue on Jul 22, 2026
    e5099cf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

  • Status
    No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions