Shaun Luttin
Shaun Luttin

Reputation: 141662

Determine where in the code a console app in release configuration has hung

I have run a .NET 5 console application in release configuration on Windows like this:

dotnet run -c RELEASE

The console app has hung after running for about three hours. Other than restarting the app e.g., in debug configuration or after adding more logging, how, if at all, can I determine where in the code the app has hung.

For instance, is there a way to attach the debugger to an app in Release mode? If not, what tool, if any, will show where the code has become stuck. Even receiving a hint about which class or line of code would be useful.

Upvotes: 0

Views: 239

Answers (1)

Leonardo
Leonardo

Reputation: 11401

Because we are talking about a release, I figured that we are also talking about a actual server that has no Visual Studio installed.

The best way to do it is to user dotnet-trace tool. Basically, all you got to do is run this for as long as necessary (paying a 25% or grater performance hit) and when you complete, you will have a report that you can run through speedscope.

Basically, the longer you see a "plato", that's where the infinite loop is

Upvotes: 1

Related Questions