5

While debugging dump files, regularly I need to check for locks, for which I use the windbg extension command !locks. When everything goes well, this provides an output like the following:

CritSec +54a8a8 at 0054a8a8
WaiterWoken        No
LockCount          0
RecursionCount     1
OwningThread       13d8
EntryCount         0
ContentionCount    0
*** Locked

CritSec +b73a8d at 00135e8d
WaiterWoken        No
LockCount          0
RecursionCount     1
OwningThread       55f3
EntryCount         0
ContentionCount    0
*** Locked

...

Scanned 662 critical sections

Sometimes, however, I get following error message:

Stopped scanning because of problem reading critical section debug info

Scanned 7 critical sections

Is it possible to have some information anyway? (E.g. where is that critical section debug info, how can I read it without the !locks command, ...)

Dominique
  • 16,450
  • 15
  • 56
  • 112
  • You can try `!cs -s -l -o` but you probably will see the same thing, you may need to enable user mode stack trace using glags `!gflag +ust` – EdChum Dec 19 '18 at 09:51

1 Answers1

4

A better alternative to !locks is to use !cs -s -l -o see !cs this will display all locked critical sections, the owner stack trace and the critical section stack trace, you can omit the -l if you want all critical sections. You may need to enable the user mode stack trace using gflags !gflag +ust remember to remove it when it isn't needed !glag -ust.

To display critical section info, you can do this if you have the address: https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/displaying-a-critical-section

so !critsec ADDRESS or using display type command dt dt RTL_CRITICAL_SECTION ADDRESS will work if you have the address.

EdChum
  • 376,765
  • 198
  • 813
  • 562
  • Thank you. Actually !cs -l is closer to !locks, and then you can display the call stack with whatever options you want. – GBrookman Mar 10 '21 at 19:06