Windbg "!locks" command doesn't work, can I get information anyway?
Asked Answered
C

1

6

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, ...)

Cartagena answered 19/12, 2018 at 9:48 Comment(1)
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 +ustAuvil
A
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.

Auvil answered 19/12, 2018 at 10:3 Comment(1)
Thank you. Actually !cs -l is closer to !locks, and then you can display the call stack with whatever options you want.Mask

© 2022 - 2024 — McMap. All rights reserved.