-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix debugger app hangs related to thread exit #114887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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