I am working on C and I have a core dump of a multithreaded (two threads) process that I am debugging. I see in gdb that the mutex_lock is acquired by both the threads under a rare situation. Is there a way I could check the thread that possess the lock in gdb? I am running a flavor of linux.. Also, I am not allowed to post the code since it's proprietary.
Asked
Active
Viewed 740 times
2
-
which operating system are you running on? – C.J. Aug 11 '11 at 05:20
-
posting some code can help better. (if possible) – hari Aug 11 '11 at 05:20
-
http://stackoverflow.com/questions/4252963/debugging-deadlock-with-pthread-mutexlinux i found similar post on SO go through it if it helps – Devjosh Aug 11 '11 at 05:22
-
Sounds like a [recursive lock](http://stackoverflow.com/questions/187761/recursive-lock-mutex-vs-non-recursive-lock-mutex). – Steve-o Aug 11 '11 at 06:14
-
I am running a flavor or Linux. I cannot add code, it's proprietary. – sril Aug 11 '11 at 08:48
1 Answers
1
On every line that gets and releases the lock in question (of course change the printf text), do the following:
break file:line
commands
printf "acquiring lock"
info threads
cont
end

steve
- 5,870
- 1
- 21
- 22
-
Thank you for the reply. I realized that in the code, while one thread had acquired a lock, another thread was doing an unlock immediately after the process starts up. This was causing both the threads to assume that they held the lock and proceed. This inturn caused an assert in one of the threads to fail leading to a core dump. – sril Aug 16 '11 at 07:53