-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Description
When debugging a .NET 7 application published in single-file mode, the .NET debugging services don't issue ICorDebugManagedCallback.CreateThread call backs, causing the threads window in Visual Studio to be missing threads.
For what it is worth, this didn't reproduce in .NET 6.
Reproduction Steps
- Create a new .NET 7 console application with the following code
dotnet publishit- Open the single file executable as an exe project in Visual Studio or another managed debugger
- Launch
- When the Debugger.Break() is hit, open the threads window or the parallel stacks window
Program.cs:
using System.Diagnostics;
void KickOffThreadPoolThread(ManualResetEvent manualResetEvent)
{
Task.Run(() =>
{
manualResetEvent.Set();
while (true)
{
Thread.Sleep(100);
}
});
}
var manualResetEvents = new ManualResetEvent[10];
for (int i = 0; i < manualResetEvents.Length; i++)
{
manualResetEvents[i] = new ManualResetEvent(false);
KickOffThreadPoolThread(manualResetEvents[i]);
}
ManualResetEvent.WaitAll(manualResetEvents);
Debugger.Break();Project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!--Enable single file-->
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>
Expected behavior
.NET Debugging services will issue ICorDebugManagedCallback.CreateThread call backs, so the parallel stacks window will have all the threads
Actual behavior
No CreateThread callback is triggered for the thread pool threads, so the parallel stacks window will only show the main thread:

Regression?
This same scenario works in .NET 6.
Known Workarounds
Debugger can call EnumerateThreads
Configuration
Version: .NET 7 RC2
OS: Windows
Architecture: x64
I didn't try other configurations other than .NET 6
Other information
No response