Skip to content

[RuntimeAsync] Live ref-like temps are seen crossing awaits in Debug/minopts codegen for IL that does not have that. #119615

Closed

Description

@VSadov

Observed while enabling rt async in Libraires partition - #119432

This triggers asserts like assert(!layout->HasGCByRef()); in AsyncTransformation::LayOutContinuation

Also see discussion in: #119432 (comment)

The actual reason is not completely known and the assert may be seen when compiling methods like:

        public static Task WhenAll(params ReadOnlySpan<Task> tasks)
        {
            switch (tasks.Length)
            {
                case 0:
                    return CompletedTask;

                case 1:
                    Task t = tasks[0];
                    if (t is null)
                    {
                        ThrowHelper.ThrowArgumentException(ExceptionResource.Task_MultiTaskContinuation_NullTask, ExceptionArgument.tasks);
                    }
                    return t;

                default:
                    return new WhenAllPromise(tasks);
            }
        }

The method itself is not async, but we generate an async thunk for it, which has the same ref-like parameter.
The thunk is simply passes the parameter to the wrapped call and does not use the parameter after the call (that is true for all parameters) and therefore nothing ref-like, or perhaps nothing at all, should need capturing into a closure.

Activity

  1. added
    area-CodeGen-coreclr
    on Sep 12, 2025
  2. added
    untriaged
    on Sep 12, 2025
  3. dotnet-policy-service commented on Sep 12, 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. changed the title [-][RuntimeAsync] Live ref-like temps are seen crossing awaits in Debug/minopts codegen when IL did not have that.[/-] [+][RuntimeAsync] Live ref-like temps are seen crossing awaits in Debug/minopts codegen for IL that does not have that.[/+] on Sep 12, 2025
  5. jakobbotsch commented on Sep 15, 2025

    @jakobbotsch
    Member

    Do you have a link to the failure for this?

  6. added this to the 11.0.0 milestone on Sep 15, 2025
  7. VSadov commented on Sep 15, 2025

    @VSadov
    MemberAuthor

    Do you have a link to the failure for this?

    I saw it in a local run. There was more than one failure. I think it requires running with -rc Checked -lc Debug.

    If we run such configuration in default CI, there should be failures due to this.

    I'll try to search for some failures for this in earlier iterations of this PR.

  8. removed
    untriaged
    on Sep 15, 2025
  9. locked and limited conversation to collaborators on Nov 23, 2025
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

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions