Fix debugger app hangs related to thread exit by tommcdon · Pull Request #114887 · dotnet/runtime
| if (m_State & TS_DebugWillSync) | ||
| { | ||
| ResetThreadState(TS_DebugWillSync); | ||
| InterlockedDecrement(&m_DebugWillSyncCount); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding an assertion or check to ensure that m_DebugWillSyncCount is positive before decrementing to avoid potential underflow if multiple thread terminations occur in succession.
| InterlockedDecrement(&m_DebugWillSyncCount); | |
| if (m_DebugWillSyncCount > 0) | |
| { | |
| InterlockedDecrement(&m_DebugWillSyncCount); | |
| } |
Copilot uses AI. Check for mistakes.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this is a regression in 9, seems like it is from the bug?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this is a regression in 9, seems like it is from the bug?
We believe that the issue has always existed, but something in .NET 9 may have caused it to happen more often. Perhaps it is a timing issue.