What causes pthread_mutex_t struct to be all zeros? Core of a deadlocked ARM test application in a gdb session:
[Switching to thread 3 (LWP 3587)] #0 __lll_lock_wait (futex=futex@entry=0x2105c <one_mutex>, private=0) at lowlevellock.c:46 46 lowlevellock.c: No such file or directory. (gdb) f 1 #1 0xaf973818 in __GI___pthread_mutex_lock (mutex=0x2105c <one_mutex>) at pthread_mutex_lock.c:81 81 pthread_mutex_lock.c: No such file or directory. (gdb) p mutex $1 = (pthread_mutex_t *) 0x2105c <one_mutex> (gdb) p (pthread_mutex_t ) 0x2105c $2 = { __data = { __lock = 0, __count = 0, __owner = 0, __kind = 0, __nusers = 0, { __spins = 0, __list = { __next = 0x0 } } }, __size = '00' <repeats 23 times>, __align = 0 }
Advertisement
Answer
pthread_mutex_t
is used for all mutex types and some of its members are only used for specific mutex types.
owner
member is set for at least the following mutex types:
PTHREAD_MUTEX_ERRORCHECK_NP
PTHREAD_MUTEX_RECURSIVE_NP
See glibc implementation of pthread_mutex_trylock
for full more details.