Skip to content

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

@VSadov

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.

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIruntime-async

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions