Skip to content

Clean up stale debugger-related surface area in ThreadPool and Task{Scheduler} #115210

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

Merged
merged 2 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,9 @@
<assembly fullname="System.Private.CoreLib" feature="System.Diagnostics.Debugger.IsSupported" featurevalue="true" featuredefault="true">
<type fullname="System.Threading.Tasks.Task">
<property name="ParentForDebugger" />
<property name="StateFlagsForDebugger" />
<property name="StateFlags" />
<method name="GetDelegateContinuationsForDebugger" />
<method name="SetNotificationForWaitCompletion" />
</type>
<type fullname="System.Threading.Timer">
<property name="AllTimers" />
</type>
<type fullname="System.Threading.Tasks.TaskScheduler">
<method name="GetScheduledTasksForDebugger" />
<method name="GetTaskSchedulersForDebugger" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ public class Task : IAsyncResult, IDisposable
internal volatile int m_stateFlags; // SOS DumpAsync command depends on this name

private Task? ParentForDebugger => m_contingentProperties?.m_parent; // Private property used by a debugger to access this Task's parent
private int StateFlagsForDebugger => m_stateFlags; // Private property used by a debugger to access this Task's state flags
private TaskStateFlags StateFlags => (TaskStateFlags)(m_stateFlags & ~(int)TaskStateFlags.OptionsMask); // Private property used to help with debugging

[Flags]
internal enum TaskStateFlags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,6 @@ internal virtual void NotifyWorkItemProgress()
{
}

/// <summary>
/// Indicates whether this is a custom scheduler, in which case the safe code paths will be taken upon task entry
/// using a CAS to transition from queued state to executing.
/// </summary>
internal virtual bool RequiresAtomicStartTransition => true;

/// <summary>
/// Calls QueueTask() after performing any needed firing of events
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,5 @@ internal override void NotifyWorkItemProgress()
{
ThreadPool.NotifyWorkItemProgress();
}

/// <summary>
/// This is the only scheduler that returns false for this property, indicating that the task entry codepath is unsafe (CAS free)
/// since we know that the underlying scheduler already takes care of atomic transitions from queued to non-queued.
/// </summary>
internal override bool RequiresAtomicStartTransition => false;
}
}
18 changes: 0 additions & 18 deletions src/libraries/System.Private.CoreLib/src/System/Threading/Timer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -973,23 +973,5 @@ public ValueTask DisposeAsync()
}

private string DisplayString => _timer._timer.DisplayString;

/// <summary>Gets a list of all timers for debugging purposes.</summary>
private static IEnumerable<TimerQueueTimer> AllTimers // intended to be used by devs from debugger
Copy link
Member

Choose a reason for hiding this comment

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

If memory serves (and the comment confirms), this wasn't used by the debugger itself but rather intended to be used by a developer in the debugger, e.g. in a watch window. It was added in #49100.

That said, I've not used this in years, I suspect few others have either, it's not documented, etc. I'd be fine removing it.

{
get
{
var timers = new List<TimerQueueTimer>();

foreach (TimerQueue queue in TimerQueue.Instances)
{
timers.AddRange(queue.GetTimersForDebugger());
}

timers.Sort((t1, t2) => t1._dueTime.CompareTo(t2._dueTime));

return timers;
}
}
}
}
Loading