dotnet/diagnostics

[dotnet-dump] Parallel stacks doesn't show threads which are waiting for a lock

En3Tho opened this issue · 2 comments

The reason is that System.Threading.Monitor.ReliableEnterTimeout(Object, Int32, Boolean ByRef) has Runtime frame kind which is not shown in current implementation.
Example output

5 RunSomethingWithLock ...
    1 ... Running ...
    ~~~ 0x1

Expected

5 RunSomethingWithLock ...
    ~~~ 0x2, 0x3, 0x4, 0x5
    1 ... Running ...
    ~~~ 0x1

Possible fix is either to add an option to include Runtime kind stack frames to pstacks output (VS for example displays "managed to native transition" when such things occur)
This will result in

5 RunSomethingWithLock ...
    4 System.Threading.Monitor.ReliableEnterTimeout(Object, Int32, Boolean ByRef)
    ~~~ 0x2, 0x3, 0x4, 0x5
    1 ... Running ...
    ~~~ 0x1

Or augment ParallelStack renderer and add a special check when displaying the stack to handle situation when there are still nested stacks present but child stacks thread count does not equal parent's

@leculver I can help fixing this either way. Adding runtime stacks support is easier I guess. Just a bool. Do you have other thought on this?

That would be great if you could put up a PR with your purposed fix.

@mikem8361 I created a small pr that implements option 1 (a parameter to include Runtime stacks too)