문제

I am trying to debug a deadlock/race condition in my multiprocess shared memory program. For some reason it is only deadlocking some of the time. I would like to know what each process is doing at this time so that I can find the bug. Any ideas on how I could use gdb or valgrind for this?

도움이 되었습니까?

해결책

Not a complete answer, just a thought:

you may attach to a working process using gdb -p <processId> /path/to/executable/being/debugged. Or just use strace -p <pid>.

BTW Right now I'm doing this for LibreOffice with KDE4 dialogs plugin hanging on startup (somewhere in libSM interaction) :) A typical race condition, because it works perfectly being run under gdb from start

다른 팁

Here's what I'd do:

  1. Recreate the issue and find the processes that are deadlocked (via top/strace).
  2. Once you get the pid, then attach to it using gdb (if it is not directly obvious from the strace output).
  3. Valgrind might not help in this case as it changes the memory layout and the reduced speed can mask the race condition.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top