Merged
Conversation
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes cDAC thread “dead” semantics by treating ThreadState.ReportDead as dead for enumeration and IsThreadMarkedDead, while still allowing callers to distinguish Dead vs ReportDead when needed (e.g., monitor-lock ownership queries).
Changes:
- Update thread enumeration and
IsThreadMarkedDeadto considerReportDeadas dead. - Extend the managed thread contract to surface
ReportDeadand convert runtime state bits into contract flags. - Adjust Thread contract documentation to reflect that raw runtime state requires conversion to the contract enum.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs | Treat ReportDead threads as dead for enumeration and IsThreadMarkedDead. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Thread_1.cs | Add mapping from runtime Thread::State bits (incl. TS_ReportDead) into contract ThreadState. |
| src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IThread.cs | Add ThreadState.ReportDead to the public contract enum. |
| docs/design/datacontracts/Thread.md | Note that Thread::State should be converted to the contract enum rather than used as a raw integer. |
...tive/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IThread.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs
Outdated
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/Dbi/DacDbiImpl.cs
Show resolved
Hide resolved
jkotas
reviewed
Apr 7, 2026
...tive/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IThread.cs
Outdated
Show resolved
Hide resolved
87ae76b to
6561442
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (1)
src/coreclr/vm/comsynchronizable.cpp:408
- ThreadNative_GetThreadState now reads the raw m_State via GetState(), but still only treats TS_Dead as "stopped". Previously GetSnapshotState() ORed TS_Dead when the reporting bit was set (now TS_Stopped), so this will fail to report shutting-down threads as stopped. Update the condition to treat TS_Stopped (and likely TS_Dead as well) as ThreadStopped to preserve behavior.
// grab a snapshot
Thread::ThreadState state = thread->GetState();
if (state & Thread::TS_Dead)
res |= ThreadNative::ThreadStopped;
...tive/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IThread.cs
Show resolved
Hide resolved
...native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Thread_1.cs
Show resolved
Hide resolved
...native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Thread_1.cs
Show resolved
Hide resolved
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/SOSDacImpl.cs
Show resolved
Hide resolved
jkotas
reviewed
Apr 11, 2026
This was referenced Apr 11, 2026
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
...native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/Thread_1.cs
Show resolved
Hide resolved
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We have to ensure that the thread is reported as dead when either
DeadorReportDeadare set. There are, however, certain cases where it is useful to distinguish between the two, for exampleGetThreadOwningMonitorLock.