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
Evaluation doesn't work because of being stopped at an unsafe gc point, but the method is not optimized #115719
changed the title [-]Evaluation on MacOS doesn't work because of being stopped at an unsafe gc point, but the method is not optimized[/-][+]Evaluation doesn't work because of being stopped at an unsafe gc point, but the method is not optimized[/+]on May 20, 2025
Hello! I would like to share some results of my investigation
This bug seems to be caused by unrolling structs with GC references(code) at the beginning of a sequence point. For such code an uninterruptible GC range is created and evaluation is prohibited according to this check
In the latest versions we encounter this bug less frequently (as I understood it thanks to #95565), but on .NET 7 it is reproduced with the following code
For a sake of experiment, I tried inserting NO_OP node before such struct stores, that emits nop instruction in the beginning of the seq point, and it fixed the issue, but I am not sure if that's the proper to do so
Could you please share your thoughts on that? How can we approach this issue?
Thanks you!
Confirming @eterekhin's diagnosis, and re-scoping this as a JIT issue.
Cause. The debugger's safe-place gate (EECodeManager::IsGcSafe) only accepts interruptible or safe-point offsets. An offset strictly inside a NoGC region is neither, so func-eval is rejected. These regions come from JIT-unrolled block copies of GC-ref structs (lowerxarch.cpp) — your ReadOnlySequence<byte> by-value copy. #103540 only exempted the region's first instruction; interior offsets are still the hole.
Current state With your repro plus three extra layouts ({int,object}, {object,object}, {object×3}), func-eval at a breakpoint on each call site succeeds on .NET 10.0.8 and 11.0.0-preview.5 (also still passes on 8.0.28 / 9.0.17). Reason it's now hard to hit: source breakpoints bind to the statement's sequence point, which sits on the region's first instruction (the offset #103540 exempts), and Break All redirects threads to safe points — so neither path lands strictly inside a region.
Fix direction (JIT). A debugger-side change would be wrong — GC genuinely can't happen inside the region. The fix would be to generalize #103540: keep a statement's sequence point from landing inside a NoGC region (or make it a real safe point) for all cases, not just the first instruction. Your NO_OP-before-store prototype does exactly this; the open question is avoiding the per-store codegen cost.
Note
This comment was generated with the assistance of AI (GitHub Copilot).
Activity
tommcdon commentedon May 19, 2025
Hi @eterekhin! Thanks for reporting this issue! I am also able to reproduce this issue on Windows x64 and on .NET 8.
[-]Evaluation on MacOS doesn't work because of being stopped at an unsafe gc point, but the method is not optimized[/-][+]Evaluation doesn't work because of being stopped at an unsafe gc point, but the method is not optimized[/+]eterekhin commentedon May 24, 2025
Hello! I would like to share some results of my investigation
This bug seems to be caused by unrolling structs with GC references(code) at the beginning of a sequence point. For such code an uninterruptible GC range is created and evaluation is prohibited according to this check
runtime/src/coreclr/debug/ee/debugger.cpp
Line 15018 in 6944091
Correspoing piece of code of Main method (from my repro code snippet) , on Windows x64
In the latest versions we encounter this bug less frequently (as I understood it thanks to #95565), but on .NET 7 it is reproduced with the following code
For a sake of experiment, I tried inserting NO_OP node before such struct stores, that emits
nopinstruction in the beginning of the seq point, and it fixed the issue, but I am not sure if that's the proper to do soCould you please share your thoughts on that? How can we approach this issue?
Thanks you!
steveisok commentedon Jul 14, 2026
Confirming @eterekhin's diagnosis, and re-scoping this as a JIT issue.
Cause. The debugger's safe-place gate (
EECodeManager::IsGcSafe) only accepts interruptible or safe-point offsets. An offset strictly inside a NoGC region is neither, so func-eval is rejected. These regions come from JIT-unrolled block copies of GC-ref structs (lowerxarch.cpp) — yourReadOnlySequence<byte>by-value copy. #103540 only exempted the region's first instruction; interior offsets are still the hole.Current state With your repro plus three extra layouts (
{int,object},{object,object},{object×3}), func-eval at a breakpoint on each call site succeeds on .NET 10.0.8 and 11.0.0-preview.5 (also still passes on 8.0.28 / 9.0.17). Reason it's now hard to hit: source breakpoints bind to the statement's sequence point, which sits on the region's first instruction (the offset #103540 exempts), and Break All redirects threads to safe points — so neither path lands strictly inside a region.Fix direction (JIT). A debugger-side change would be wrong — GC genuinely can't happen inside the region. The fix would be to generalize #103540: keep a statement's sequence point from landing inside a NoGC region (or make it a real safe point) for all cases, not just the first instruction. Your
NO_OP-before-store prototype does exactly this; the open question is avoiding the per-store codegen cost.Note
This comment was generated with the assistance of AI (GitHub Copilot).
dotnet-policy-service commentedon Jul 14, 2026
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.
JulieLeeMSFT commentedon Jul 15, 2026
@AndyAyersMS, PTAL.
JIT: handle adjacent no-GC regions (#115719) (#130834)
JIT: handle adjacent no-GC regions (dotnet#115719) (dotnet#130834)