Fix Monitor.Wait unregistration in CoreCLR upon a thread exiting#112797
Closed
kouvel wants to merge 2 commits intodotnet:mainfrom
kouvel:UnregisterWaitsBeforeExit
Closed
Fix Monitor.Wait unregistration in CoreCLR upon a thread exiting#112797kouvel wants to merge 2 commits intodotnet:mainfrom kouvel:UnregisterWaitsBeforeExit
Monitor.Wait unregistration in CoreCLR upon a thread exiting#112797kouvel wants to merge 2 commits intodotnet:mainfrom
kouvel:UnregisterWaitsBeforeExit
Conversation
Moved the Monitor wait unregistration to happen just before the thread exits, since the wait info is allocated on the stack. Monitor waits are not typically unregistered here, but there can be some odd cases.
Contributor
|
Tagging subscribers to this area: @mangod9 |
This was referenced Feb 22, 2025
Open
Member
|
Assume this is a presumptive fix for #97034.? |
mangod9
reviewed
Feb 25, 2025
| m_ThreadHandleForClose = hThread; | ||
| } | ||
|
|
||
| UnregisterWaitEventLinks(); |
Member
There was a problem hiding this comment.
can this be called from CooperativeCleanup ?
Contributor
Author
There was a problem hiding this comment.
CooperativeCleanup seemingly intends to do cleanup in cooperative GC mode, which is not necessary for cleaning up the wait event links.
Contributor
Author
It seems unlikely given how corner a case it would be (exiting a thread abruptly during a wait). A similar crash could occur in such a case, though it could also occur due to memory corruption or something else abnormal. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moved the Monitor wait unregistration to happen just before the thread exits, since the wait info is allocated on the stack. Monitor waits are not typically unregistered here, but there can be some odd cases.