Вопрос

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