-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Ensure consistency between ThreadState.Stopped APIs that check if a thread is dead #122568
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
…hread is dead. When a managed thread dies, set _isDead, and make _isDead short-circuit thread state fetching
|
Tagging subscribers to this area: @mangod9 |
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 pull request improves consistency in how thread death is reported by consolidating the mechanism to use the _isDead field instead of the TS_ReportDead thread state flag. The change simplifies the threading model by having the managed code directly check _isDead before querying the native thread state, rather than relying on a QCall to set TS_ReportDead.
- Removes the
ThreadNative_ReportDeadQCall and its infrastructure - Updates
ThreadNative_GetThreadStateto include other thread state flags even when the thread is dead (aligning with debugger interface behavior) - Makes the
ThreadStateproperty short-circuit to returnThreadState.Stoppedwhen_isDeadis true, avoiding unnecessary native calls
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/vm/qcallentrypoints.cpp | Removes the ThreadNative_ReportDead QCall entry point |
| src/coreclr/vm/comsynchronizable.h | Removes the ThreadNative_ReportDead function declaration |
| src/coreclr/vm/comsynchronizable.cpp | Removes the ThreadNative_ReportDead function implementation and updates ThreadNative_GetThreadState to OR the ThreadStopped flag instead of early-returning when a thread is dead |
| src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs | Adds early return in ThreadState property when _isDead is true; removes ReportDead P/Invoke and NotifyThreadDeath method; sets _isDead = true at the start of OnThreadExiting |
src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs
Outdated
Show resolved
Hide resolved
….CoreCLR.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs
Show resolved
Hide resolved
…ntime into thread-state-fix
When a managed thread dies, set _isDead, and make _isDead short-circuit thread state fetching instead of setting the ReportDead state before we do unmanaged thread cleanup.
Fixes #122520