Skip to content

Fix Monitor.Wait unregistration in CoreCLR upon a thread exiting #112797

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

Closed
wants to merge 2 commits into from

Conversation

kouvel
Copy link
Contributor

@kouvel kouvel commented Feb 21, 2025

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.

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.
@kouvel kouvel added this to the 10.0.0 milestone Feb 21, 2025
@kouvel kouvel self-assigned this Feb 21, 2025
@Copilot Copilot AI review requested due to automatic review settings February 21, 2025 19:27
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 1 out of 3 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • src/coreclr/vm/threads.cpp: Language not supported
  • src/coreclr/vm/threads.h: Language not supported

Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@mangod9
Copy link
Member

mangod9 commented Feb 25, 2025

Assume this is a presumptive fix for #97034.?

@@ -930,6 +930,7 @@ HRESULT Thread::DetachThread(BOOL fDLLThreadDetach)
m_ThreadHandleForClose = hThread;
}

UnregisterWaitEventLinks();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be called from CooperativeCleanup ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CooperativeCleanup seemingly intends to do cleanup in cooperative GC mode, which is not necessary for cleaning up the wait event links.

@kouvel
Copy link
Contributor Author

kouvel commented Feb 25, 2025

Assume this is a presumptive fix for #97034.?

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.

@jkotas jkotas requested a review from VSadov February 25, 2025 15:25
@kouvel kouvel closed this by deleting the head repository May 14, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jun 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants