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
[Interpreter] A branch to itself gets no safepoint, so a thread in while (true) { } blocks GC suspension #135465
With the CoreCLR interpreter (DOTNET_InterpMode=1), an empty infinite loop branches to itself without a safepoint, so a thread spinning in it cannot be suspended and the next GC hangs the process. I plan to open a PR that adds the missing safepoint, fixes a related thread-abort attribution problem (described below), and adds tests.
while (true) { } compiles to L: br.s L. InterpCompiler::EmitBranch emits INTOP_SAFEPOINT only when ilOffset < 0, and its callers pass the offset relative to the start of the branch instruction (2 + disp for br.s, 5 + offset for br). So a branch to itself has offset 0 and gets no safepoint. DOTNET_InterpDump shows the loop as a br that targets itself with no safepoint before it. Cancelling such a loop with ControlledExecution never completes either.
Fix
In a local build, changing the condition to ilOffset <= 0 fixes the repro on linux-x64. With that change, a try region whose body is the loop can begin with the safepoint in front of the branch. That exposes a thread-abort attribution problem: INTOP_SAFEPOINT records the start of the instruction, but HandleThreadAbort dispatches the abort as if from a call. So an abort raised at that safepoint is attributed to the instruction before the region. The PR will fix both.
Note
This issue was drafted with AI assistance (Anthropic Claude). The runs it cites were done at commit 6ff62b1.
@BrzVlad I've opened #135467 for this. While fixing it I found that a backward leave (for example while (true) { try { ... } catch { ... } }) and a backward switch have the same gap; the PR covers all three, with a test, and is validated on linux-x64, osx-arm64 and windows-x64.
Note
This comment was prepared with AI assistance (Anthropic Claude).
Activity
dotnet-policy-service commentedon Oct 9, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @VSadov
See info in area-owners.md if you want to be subscribed.
dotnet-policy-service commentedon Oct 9, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @BrzVlad, @janvorli
See info in area-owners.md if you want to be subscribed.
pcshrosbree commentedon Oct 9, 2026
@BrzVlad I've opened #135467 for this. While fixing it I found that a backward
leave(for examplewhile (true) { try { ... } catch { ... } }) and a backwardswitchhave the same gap; the PR covers all three, with a test, and is validated on linux-x64, osx-arm64 and windows-x64.Note
This comment was prepared with AI assistance (Anthropic Claude).
[Interpreter] Emit a safepoint for a backward leave and a backward sw…