Skip to content

JIT: Support for flowing contexts is missing in runtime async #116523

Open
@jakobbotsch

Description

@jakobbotsch

This is one of the known missing pieces for a long time. Just opening an issue to track it.

The JIT needs to generate code to properly flow these contexts around all runtime async calls.

// Generated by Fuzzlyn v3.3 on 2025-06-11 10:40:39
// Run on X64 Windows
// Seed: 5746771873810961189-async,runtimeasync,vectort,vector128,vector256,x86aes,x86avx,x86avx2,x86bmi1,x86bmi1x64,x86bmi2,x86bmi2x64,x86fma,x86lzcnt,x86lzcntx64,x86pclmulqdq,x86pclmulqdqv256,x86popcnt,x86popcntx64,x86sse,x86ssex64,x86sse2,x86sse2x64,x86sse3,x86sse41,x86sse41x64,x86sse42,x86sse42x64,x86ssse3,x86x86base
// Reduced from 64.2 KiB to 0.5 KiB in 00:00:41
// Release: Runs successfully
// Release with Runtime Async: Throws 'System.InvalidOperationException'
using System.Threading;
using System.Threading.Tasks;

public class Program
{
    public static AsyncLocal<long?> s_asyncLocal1 = new AsyncLocal<long?>();
    public static void Main()
    {
        bool vr1 = 0 >= M1().GetAwaiter().GetResult();
    }

    public static async Task<int> M1()
    {
        s_asyncLocal1.Value = 0;
        await Task.Yield();
        long vr2 = s_asyncLocal1.Value.Value;
        System.Console.WriteLine(vr2);
        long vr3 = s_asyncLocal1.Value.Value;
        return (byte)vr3;
    }
}

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

Relationships

None yet

Development

No branches or pull requests

Issue actions