Skip to content

Commit

Permalink
Fix jit attach hang at Shutdown (dotnet#67166)
Browse files Browse the repository at this point in the history
Fixes dotnet#66715

We are seeing exceptions thrown at shutdown turn into hangs because the debugger
lock suspends threads at that point. We are mitigating that problem by disabling the
jit attach setup work and allowing WatsonLastChance to continue.
  • Loading branch information
noahfalk authored and radekdoulik committed Mar 30, 2022
1 parent 83a28e3 commit 57c9c64
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/coreclr/debug/ee/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6946,6 +6946,18 @@ BOOL Debugger::PreJitAttach(BOOL willSendManagedEvent, BOOL willLaunchDebugger,

LOG( (LF_CORDB, LL_INFO10000, "D::PreJA: Entering\n") );

if (m_fShutdownMode)
{
// Trying to JitAttach because of some failure at shutdown is likely to block because we
// would suspend any thread that isn't the finalizer or debugger helper thread when it tries to
// take the debugger lock below. By bailing out here we won't do the JitAttach as we normally
// would, but at least the app should exit with an unhandled exception or FailFast rather
// entering a hung state. We believe this is very rare scenario so mitigating the problem in
// this way is sufficient.
LOG( (LF_CORDB, LL_INFO10000, "D::PreJA: Leaving - shutdown case\n") );
return FALSE;
}

// Multiple threads may be calling this, so need to take the lock.
if(!m_jitAttachInProgress)
{
Expand Down

0 comments on commit 57c9c64

Please sign in to comment.