I am using a recursive mutex which is defined in shared memory for synchronization between two processes. I am seeing a deadlock between two processes but when I debugged core file, I found out that neither process A nor process B is owning the lock but both are trying to take the lock. We can see below that in both the process owner of the lock is 0.
Process A:
(gdb) bt
#0 0x0fb4e06c in __pthread_mutex_lock_full (mutex=0x4583efa4) at ../nptl/pthread_mutex_lock.c:310
#1 0x0fb4e31c in __GI___pthread_mutex_lock (mutex=mutex@entry=0x4583efa4) at ../nptl/pthread_mutex_lock.c:73
(gdb) p *mutex
$3 = {__data = {__lock = -2147483648, __count = 0, __owner = 0, __kind = 145, __nusers = 0, {__elision_data = {__espins = -18453, __elision = -24448}, __list = {
__next = 0xb7eba080}}}, __size = "\200", '\000' <repeats 14 times>, "\221\000\000\000\000\267\353\240\200", __align = -2147483648}
(gdb)
Process B:
(gdb)
#0 0x0fb4e06c in __pthread_mutex_lock_full (mutex=0x4583efa4) at ../nptl/pthread_mutex_lock.c:310
#1 0x0fb4e31c in __GI___pthread_mutex_lock (mutex=mutex@entry=0x4583efa4) at ../nptl/pthread_mutex_lock.c:73
(gdb) p *mutex
$3 = {__data = {__lock = -2147483648, __count = 0, __owner = 0, __kind = 145, __nusers = 0, {__elision_data = {__espins = -18453, __elision = -24448}, __list = {
__next = 0xb7eba080}}}, __size = "\200", '\000' <repeats 14 times>, "\221\000\000\000\000\267\353\240\200", __align = -2147483648}
(gdb)
This seems very strange to me, may I know what is your first thought about it?
Can someone provide me some information about it please?