`dotnet-trace collect` hangs without completing collection on Linux
Description
When attempting to use dotnet-trace collect command on a running application, the command hangs indefinitely. It neither completes the collection nor responds to enter or Ctrl+C inputs.
The steps to reproduce this issue on my setup:
- Run
dotnet-trace psto find the PID. The PID of my application was found as expected and was the only one on the list. - Execute
dotnet-trace collect -p <PID> --duration 00:00:01
At this point, the output is:
No profile or providers specified, defaulting to trace profile 'cpu-sampling'
Provider Name Keywords Level Enabled By
Microsoft-DotNETCore-SampleProfiler 0x0000F00000000000 Informational(4) --profile
Microsoft-Windows-DotNETRuntime 0x00000014C14FCCBD Informational(4) --profile
However, the program does not proceed from this point. It does not respond to enter or Ctrl+C inputs and remains stuck indefinitely. This behavior occurs with and without the --duration option.
In contrast, when running dotnet-stack for the same application, it works as expected, yet dotnet-trace and dotnet-dump do not.
The expected output for the dotnet-trace collect command should look something like:
No profile or providers specified, defaulting to trace profile 'cpu-sampling'
Provider Name Keywords Level Enabled By
Microsoft-DotNETCore-SampleProfiler 0x0000F00000000000 Informational(4) --profile
Microsoft-Windows-DotNETRuntime 0x00000014C14FCCBD Informational(4) --profile
Process : E:\temp\gcperfsim\bin\Debug\net5.0\gcperfsim.exe
Output File : E:\temp\gcperfsim\trace.nettrace
[00:00:00:05] Recording trace 122.244 (KB)
Press <Enter> or <Ctrl+C> to exit...
Configuration
The host OS is Ubuntu 20.04, container is mcr.microsoft.com/dotnet/sdk:7.0, running the application as ./ApplicationName (also tried dotnet ApplicationName.dll). Tool 'dotnet-trace' was reinstalled with the latest stable version (version '7.0.421201')
.NET SDK:
Version: 7.0.302
Commit: 990cf98a27
Runtime Environment:
OS Name: debian
OS Version: 11
OS Platform: Linux
RID: debian.11-x64
Base Path: /usr/share/dotnet/sdk/7.0.302/
Host:
Version: 7.0.5
Architecture: x64
Commit: 8042d61b17
.NET SDKs installed:
7.0.302 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.5 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.5 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Other information
This issue is not specific to .NET 7. I've also tested it in .NET 6 using the corresponding Docker image, and the behavior remains the same. The issue occurs with both self-contained and non-self-contained builds, on the host OS and in containers. Any help or pointers in resolving this issue would be greatly appreciated.