Fix debugger app hangs related to thread exit#114887
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the debugger app hang issue on thread termination by correctly managing m_DebugWillSyncCount when a thread exits before synchronization.
- Added a check for TS_DebugWillSync in OnThreadTerminate
- Reset the thread state and decremented the debug sync counter accordingly
| if (m_State & TS_DebugWillSync) | ||
| { | ||
| ResetThreadState(TS_DebugWillSync); | ||
| InterlockedDecrement(&m_DebugWillSyncCount); |
There was a problem hiding this comment.
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); | |
| } |
There was a problem hiding this comment.
Is this is a regression in 9, seems like it is from the bug?
There was a problem hiding this comment.
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.
|
Tagging subscribers to this area: @mangod9 |
|
/backport to release/9.0-staging |
|
Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/14598643076 |
…e it is synchronized (dotnet#114887)" This reverts commit 28bbd27.
This fix correctly manages m_DebugWillSyncCount when thread exits before it is synchronized, addressing #112747