You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JIT: (bug) loop left partially interruptible after morph removes the stelem.ref call (GC suspension hang) #134894
When a non-inlined CastHelpers.StelemRef user call storing null is replaced by a plain STOREIND in morph, the block keeps a stale BBF_GC_SAFE_POINT flag. A call-free loop is then emitted partially interruptible and GC suspension hangs forever.
Minimal Repro
usingSystem;usingSystem.Runtime.CompilerServices;usingSystem.Threading;publicclassProgram{staticvolatilebools_started;staticints_x;[MethodImpl(MethodImplOptions.AggressiveInlining)]staticvoidF6(){s_x++;}[MethodImpl(MethodImplOptions.AggressiveInlining)]staticvoidF5(){F6();F6();F6();F6();}[MethodImpl(MethodImplOptions.AggressiveInlining)]staticvoidF4(){F5();F5();F5();F5();}[MethodImpl(MethodImplOptions.AggressiveInlining)]staticvoidF3(){F4();F4();F4();F4();}[MethodImpl(MethodImplOptions.AggressiveInlining)]staticvoidF2(){F3();F3();F3();F3();}staticvoidF1()=>F2();// exhausts the inline budget, so StelemRef can't be inlined[MethodImpl(MethodImplOptions.NoInlining|MethodImplOptions.AggressiveOptimization)]staticvoidTest(object[]arr,inti){F1();s_started=true;while(true){objecto=null;arr[i]=o;}}staticvoidMain(){vart=newThread(()=>Test(newstring[10],1)){IsBackground=true};t.Start();while(!s_started){}Thread.Sleep(100);GC.Collect();Console.WriteLine("Done");}}
Expected
Done
Actual
The process hangs in GC.Collect(). Test is reported as ; partially interruptible while its loop contains no call.
Regression?
Yes. .NET 8, 9 and 10 print Done; .NET 11 RC2 and main hang.
Notes
fgMorphCall sets BBF_GC_SAFE_POINT while the call is still CT_USER_FUNC, then the "stelem of null" optimization replaces the call with a STOREIND. The flag is never cleared, so fgHasCycleWithoutGCSafePoint thinks the loop has a safe point.
Became reachable in .NET 11 when stelem.ref started being imported as a user call to CastHelpers.StelemRef.
Activity
dotnet-policy-service commentedon Sep 29, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
JIT: mark GC safe point after stelem.ref call transformation (#134973)