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
#123650 was closed and fixed by #123651.
However, the issue can still reproduce even with the fix applied, see original issue for stacks.
Reproduction Steps
Debug a dotnet 10 application with VS.
Expected behavior
Debuggee run as expected.
Actual behavior
Runtime can deadlock internally.
Regression?
No response
Known Workarounds
None known.
Configuration
.NET 10 windows x64 is where the issue was spotted but code analysis suggests the race condition could probably be hit on other .NET versions, OSes, and architectures if timed properly.
In the repro cases shared I can see 10.0.5 being run. In it the debugger is stopped on events, and the runtime has a few threads waiting to send events - JIT events, exceptions, potentially the reply to the message itself - but they can't since the DebuggerControllerLock is being held in this similar case:
So, the fence post did move a little - We didn't call GetJitInfo during BindPatch for this case looks like, but we end up in another hash lookup during:
And potentially any thread starter or JIT complete notification when the debugger is attached is going to hit this race too... For example, in Debugger::JITComplete we do create the DJI before holding the controller lock in MapAndBindFunctionPatches, but any PtrHashMap/HashMap lookup after is going to cause issues. In particular, this one is needed to find the cold/hot split in the method. I need to investigate a little more since the DJI already seems to have the data initialized, so it's unclear why it went down this path. I'd have expected preinitialization to be a good workaround for the stack in particular.
On release/10.0, the debugger can deadlock while binding an IL breakpoint to ReadyToRun code. A thread holds CrstDebuggerController, lazily loads the method's sequence map, and enters HashMap::LookupValue. The lookup transitions the thread from preemptive to cooperative GC mode. If debugger suspension is active, the transition blocks while the controller lock remains held, preventing debugger synchronization from completing.
The method's sequence map has not been initialized.
A GC or debugger suspension races with the lookup.
Other controller-lock-held paths can reach the same transition through GetJitInfo, GetJitInfoFromAddr, GetNativeCodeMethodDesc, GetNativeCodeStartAddress, or CodeRegionInfo. This includes breakpoint binding, JMC step-in, COM/VSD stepping, and single-stepping through ReadyToRun code.
It is separate from the shutdown/ThreadStore deadlock mentioned above. Current main avoids this transition through ebr but that's a riskier port. release/10.0 remains vulnerable in the LazyInitBounds path.
Activity
dotnet-policy-service commentedon Mar 25, 2026
Tagging subscribers to this area: @steveisok, @thaystg, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.
dotnet-policy-service commentedon Mar 27, 2026
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.
hoyosjs commentedon Mar 27, 2026
In the repro cases shared I can see 10.0.5 being run. In it the debugger is stopped on events, and the runtime has a few threads waiting to send events - JIT events, exceptions, potentially the reply to the message itself - but they can't since the
DebuggerControllerLockis being held in this similar case:So, the fence post did move a little - We didn't call
GetJitInfoduringBindPatchfor this case looks like, but we end up in another hash lookup during:runtime/src/coreclr/debug/ee/controller.cpp
Line 1458 in 4900ec8
And potentially any thread starter or JIT complete notification when the debugger is attached is going to hit this race too... For example, in
Debugger::JITCompletewe do create the DJI before holding the controller lock inMapAndBindFunctionPatches, but anyPtrHashMap/HashMaplookup after is going to cause issues. In particular, this one is needed to find the cold/hot split in the method. I need to investigate a little more since the DJI already seems to have the data initialized, so it's unclear why it went down this path. I'd have expected preinitialization to be a good workaround for the stack in particular.hoyosjs commentedon Mar 27, 2026
Another few paths with this issue:
And notably,
GetJitInforeturning null here will git GetCodeRegionInfo's hashmap too.Another case for COM and VSD at :
SS through R2R (not common):
Also pretty much anything that touches r2r with this shape:
hoyosjs commentedon Mar 28, 2026
#126247 has a workaround for the 2 cases that have been reported in the wild.
hoyosjs commentedon Apr 22, 2026
As a possible workaround for folks hitting this: Setting DOTNET_ReadyToRun=0 before debugging should avoid most of the cases where this could happen.
[Release/10.0] Pass down DJI and MethodDesc to avoid unnecessary PtrH…
hoyosjs commentedon Jul 11, 2026
main already solved this via EBR
6 remaining items
steveisok commentedon Aug 20, 2026
@hoyosjs in case this helps - https://gist.github.com/steveisok/ae066d547c8bd8f63473c623a1a85bc7
fix(sandbox): resolve C# uncaught-exception silent-completion bug (3 …
hoyosjs commentedon Sep 2, 2026
On
release/10.0, the debugger can deadlock while binding an IL breakpoint to ReadyToRun code. A thread holdsCrstDebuggerController, lazily loads the method's sequence map, and entersHashMap::LookupValue. The lookup transitions the thread from preemptive to cooperative GC mode. If debugger suspension is active, the transition blocks while the controller lock remains held, preventing debugger synchronization from completing.The required conditions are:
Other controller-lock-held paths can reach the same transition through
GetJitInfo,GetJitInfoFromAddr,GetNativeCodeMethodDesc,GetNativeCodeStartAddress, orCodeRegionInfo. This includes breakpoint binding, JMC step-in, COM/VSD stepping, and single-stepping through ReadyToRun code.It is separate from the shutdown/ThreadStore deadlock mentioned above. Current
mainavoids this transition through ebr but that's a riskier port.release/10.0remains vulnerable in theLazyInitBoundspath.steveisok commentedon Sep 2, 2026
@hoyosjs how risky would #124307 be to backport?
steveisok commentedon Sep 2, 2026
Alternatives may be more a game of whack-a-mole.
[Release/10.0] Initialize debugger sequence map before binding patches (
Release ThreadStore lock before blocking for shutdown (#133049)
[release/11.0] Release ThreadStore lock before blocking for shutdown (#…
[release/10.0] Release ThreadStore lock before blocking for shutdown (#…