Skip to content

Assertion failed 'node->AsCall()->IsAsync()' #122582

Closed

Description

@MichalStrehovsky

Hitting this with native AOT, only when optimizations are disabled (/p:Optimize=false).

Repro steps:

  1. Add:
  <PropertyGroup>
    <Features>$(Features);runtime-async=on</Features>
    <NoWarn>$(NoWarn);xUnit1013;CS1998;SYSLIB5007</NoWarn>
  </PropertyGroup>>

At the bottom of src\libraries\Directory.Build.props.

  1. build.cmd clr.aot+libs -rc Checked -lc Release
  2. dotnet.cmd build src\libraries\System.Text.Json\tests\System.Text.Json.SourceGeneration.Tests\System.Text.Json.SourceGeneration.Roslyn4.4.Tests.csproj -c Release /p:RuntimeConfiguration=Checked /p:TestNativeAot=true /p:Optimize=false -f net11.0

Hitting:

  ILC: D:\git\runtime3\src\coreclr\jit\lower.cpp:5930
  ILC: Assertion failed 'node->AsCall()->IsAsync()' in 'System.Text.Json.Serialization.Tests.StreamingJsonSerializerWrapper:DeserializeWrapper[System.Text.Json.Serialization.Tests.Struct_With_Ctor_With_65_Params](System.String,System.Text.Json.JsonSerializerOptions):System.Threading.Tasks.Task`1[System.Text.Json.Serialization.Tests.Struct_With_Ctor_With_65_Params]:this' during 'Lowering nodeinfo' (IL size 76; hash 0x61a38a3d; MinOpts)

Activity

  1. added
    area-CodeGen-coreclr
    on Dec 16, 2025
  2. added
    untriaged
    on Dec 16, 2025
  3. dotnet-policy-service commented on Dec 16, 2025

    @dotnet-policy-service
    Contributor

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

  4. jakobbotsch commented on Dec 16, 2025

    @jakobbotsch
    Member

    It means NativeAOT is using the AsyncCallContinuation intrinsic on a call that was not marked with runtime async call convention when the JIT queried the calling convention. This is most likely a NAOT issue.

  5. removed
    area-CodeGen-coreclr
    on Dec 16, 2025
  6. dotnet-policy-service commented on Dec 16, 2025

    @dotnet-policy-service
    Contributor

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

  7. MichalStrehovsky commented on Dec 16, 2025

    @MichalStrehovsky
    MemberAuthor

    It means NativeAOT is using the AsyncCallContinuation intrinsic on a call that was not marked with runtime async call convention when the JIT queried the calling convention. This is most likely a NAOT issue.

    Here's JitDump:
    issue122582.txt

    The parts that look relevant:

        [ 3]  11 (0x00b) call 0A000002
    In Compiler::impImportCall: opcode is call, kind=0, callRetType is struct, structSize is 260
    Call is an async non-task await
    
        [ 0]  17 (0x011) call 0A000003
    In Compiler::impImportCall: opcode is call, kind=0, callRetType is ref, structSize is 0
    Named Intrinsic System.Runtime.CompilerServices.AsyncHelpers.AsyncCallContinuation: Recognized****
    

    Looks like the previous call was reported as async?

  8. jakobbotsch commented on Dec 17, 2025

    @jakobbotsch
    Member

    It means NativeAOT is using the AsyncCallContinuation intrinsic on a call that was not marked with runtime async call convention when the JIT queried the calling convention. This is most likely a NAOT issue.

    Here's JitDump: issue122582.txt

    The parts that look relevant:

        [ 3]  11 (0x00b) call 0A000002
    In Compiler::impImportCall: opcode is call, kind=0, callRetType is struct, structSize is 260
    Call is an async non-task await
    
        [ 0]  17 (0x011) call 0A000003
    In Compiler::impImportCall: opcode is call, kind=0, callRetType is ref, structSize is 0
    Named Intrinsic System.Runtime.CompilerServices.AsyncHelpers.AsyncCallContinuation: Recognized****
    

    Looks like the previous call was reported as async?

    Yes, indeed.
    From a quick reading it looks like the stloc between the call and AsyncCallContinuation is making a call appear between them that gets the JIT confused. I think the JIT can work a bit harder to match the intrinsic to the preceding call now after #121952. I can look at that from the JIT side (after new years).

    Alternatively the IL can be shaped to avoid the stloc between them -- that may or may not work.

  9. added
    area-CodeGen-coreclr
    and removed
    untriaged
    on Dec 17, 2025
  10. self-assigned this
    on Dec 17, 2025
  11. added this to the 11.0.0 milestone on Dec 17, 2025
  12. dotnet-policy-service commented on Dec 17, 2025

    @dotnet-policy-service
    Contributor

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

  13. MichalStrehovsky commented on Dec 17, 2025

    @MichalStrehovsky
    MemberAuthor

    The stloc is not a native AOT invention, CoreCLR also has it:

    pCode->EmitCALL(token, localArg, logicalResultLocal != UINT_MAX ? 1 : 0);
    if (logicalResultLocal != UINT_MAX)
    pCode->EmitSTLOC(logicalResultLocal);
    pCode->EmitCALL(METHOD__ASYNC_HELPERS__ASYNC_CALL_CONTINUATION, 0, 1);
    pCode->EmitBRFALSE(finishedLabel);

    It's odd we're not seeing this in CoreCLR testing.

  14. jakobbotsch commented on Dec 18, 2025

    @jakobbotsch
    Member

    It's possible we never JIT the thunks without optimizations in the coreclr testing, or that there are other differences between coreclr and NativeAOT for when RyuJIT uses a helper call for a struct copy.

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

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrruntime-async

Type

No type

Projects

  • Status
    No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions