Open
Description
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;
}
}