Discussion:
Thread holding mutext
(too old to reply)
Maanu
2010-06-24 08:13:32 UTC
Permalink
Raw Message
Hi,

I would like to know which thread is currently holding (locking) a mutex. Is
it possible to identify that with Windbg or other windows debugger tools?

Thanks!
Scott Noone
2010-06-24 11:38:57 UTC
Permalink
Raw Message
User mode or kernel mode?

-scott
--
Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com
Post by Maanu
Hi,
I would like to know which thread is currently holding (locking) a mutex. Is
it possible to identify that with Windbg or other windows debugger tools?
Thanks!
Maanu
2010-06-24 13:57:44 UTC
Permalink
Raw Message
user mode
Post by Scott Noone
User mode or kernel mode?
-scott
--
Scott Noone
Consulting Associate
OSR Open Systems Resources, Inc.
http://www.osronline.com
Post by Maanu
Hi,
I would like to know which thread is currently holding (locking) a mutex. Is
it possible to identify that with Windbg or other windows debugger tools?
Thanks!
Kjell Gunnar
2010-06-24 12:36:12 UTC
Permalink
Raw Message
If it is usermode, the processExplorer can help you

http://stackoverflow.com/questions/801284/is-there-a-tool-to-monitor-synchronisation-objects-mutex-events-semaphores-in
Post by Maanu
Hi,
I would like to know which thread is currently holding (locking) a mutex. Is
it possible to identify that with Windbg or other windows debugger tools?
Thanks!
Maanu
2010-06-24 13:57:45 UTC
Permalink
Raw Message
Hi,

I can view the mutex objects. But I cannot see which thread currently
owning the mutex.
Post by Kjell Gunnar
If it is usermode, the processExplorer can help you
http://stackoverflow.com/questions/801284/is-there-a-tool-to-monitor-synchronisation-objects-mutex-events-semaphores-in
Post by Maanu
Hi,
I would like to know which thread is currently holding (locking) a mutex. Is
it possible to identify that with Windbg or other windows debugger tools?
Thanks!
Kjell Gunnar
2010-06-25 08:19:36 UTC
Permalink
Raw Message
Right click on the line showing the Mutant of interest, and then observe the
Mutant info.
If mutant is held, you get the pid and thread id, both in decimal.
(I just tested it on XP sp3, ProcessExplorer v11.33)

Regards
Kjell Gunnar
Post by Maanu
Hi,
I can view the mutex objects. But I cannot see which thread currently
owning the mutex.
Post by Kjell Gunnar
If it is usermode, the processExplorer can help you
http://stackoverflow.com/questions/801284/is-there-a-tool-to-monitor-synchronisation-objects-mutex-events-semaphores-in
Post by Maanu
Hi,
I would like to know which thread is currently holding (locking) a mutex. Is
it possible to identify that with Windbg or other windows debugger tools?
Thanks!
Krzysztof Uchronski
2010-06-24 14:41:05 UTC
Permalink
Raw Message
Depending on whether you need to that in KM or UM.

If you can use KD, you can try this:
1) Get EPROCESS pointer for your process:
!process 0 0 binary_name.exe
2) Dump all mutexes that belongs to your process:
!handle 0 2 <eprocess_address_from_step1> Mutant
or alternatively if you have UM handle value:
!handle <handle_value> 2 <eprocess_address_from_step1>
3) Dump mutant structure with the object address of the mutant you are
interested in:
dt nt!_KMUTANT <mutex_address_from_step2> OwnerThread
4) Having owning thread KTHREAD pointer you can see its callstack, owning
process, etc.:
!thread <kthread_address_from_step3> 1f

I'm not sure about UM case. You can probably get some info about mutexes
with !handle <handle>.

Kris

-----Original Message-----
From: Maanu [mailto:***@discussions.microsoft.com]
Posted At: Thursday, June 24, 2010 9:14 AM
Posted To: microsoft.public.windbg
Conversation: Thread holding mutext
Subject: Thread holding mutext

Hi,

I would like to know which thread is currently holding (locking) a mutex.
Is
it possible to identify that with Windbg or other windows debugger tools?

Thanks!
Krzysztof Uchronski
2010-06-24 15:14:33 UTC
Permalink
Raw Message
I just realize that you can probably go with something much simplier:
!process 0 2

It should give you a list of all processes and its threads with their
waiting states.

Alternatively if you know that mutex is only used by threads that belongs
to one process:
!process 0 2 <binary_name.exe>

You can then grep the list for "Mutant - owning thread" string or
something similar to see who's owning your mutex.

Kris

-----Original Message-----
From: Krzysztof Uchronski [mailto:***@biglasagne.com]
Posted At: Thursday, June 24, 2010 3:41 PM
Posted To: microsoft.public.windbg
Conversation: Thread holding mutext
Subject: Re: Thread holding mutext

Depending on whether you need to that in KM or UM.

If you can use KD, you can try this:
1) Get EPROCESS pointer for your process:
!process 0 0 binary_name.exe
2) Dump all mutexes that belongs to your process:
!handle 0 2 <eprocess_address_from_step1> Mutant
or alternatively if you have UM handle value:
!handle <handle_value> 2 <eprocess_address_from_step1>
3) Dump mutant structure with the object address of the mutant you are
interested in:
dt nt!_KMUTANT <mutex_address_from_step2> OwnerThread
4) Having owning thread KTHREAD pointer you can see its callstack, owning
process, etc.:
!thread <kthread_address_from_step3> 1f

I'm not sure about UM case. You can probably get some info about mutexes
with !handle <handle>.

Kris

-----Original Message-----
From: Maanu [mailto:***@discussions.microsoft.com]
Posted At: Thursday, June 24, 2010 9:14 AM
Posted To: microsoft.public.windbg
Conversation: Thread holding mutext
Subject: Thread holding mutext

Hi,

I would like to know which thread is currently holding (locking) a mutex.
Is
it possible to identify that with Windbg or other windows debugger tools?

Thanks!
r***@googlemail.com
2015-06-23 14:12:59 UTC
Permalink
Raw Message
Post by Maanu
Hi,
I would like to know which thread is currently holding (locking) a mutex. Is
it possible to identify that with Windbg or other windows debugger tools?
Thanks!
run this command:

0:000> !handle 0 f Mutant
Handle 2c
Type Mutant
Attributes 0
GrantedAccess 0x1f0001:
Delete,ReadControl,WriteDac,WriteOwner,Synch
QueryState
HandleCount 2
PointerCount 65537
Name \Sessions\1\BaseNamedObjects\muhaha
Object Specific Information
Mutex is Owned
Mutant Owner 226c.3550
1 handles of type Mutant

the owner pid is 226c, the tid is 3550

Loading...