I have an Apache module on Mac OS X that produces random crashes. I can reproduce these crashes with certain sequence of actions, and these crashes produce Crash Reporter dialog “httpd quit unexpectedly”. Is there a way to cause Crash Reporter launch debugger (xcode, gdb, anything) instead of just displaying the backtrace?
I’ve tried running httpd under gdb with httpd -X but the crash doesn’t happen then – it happens only if many httpd’s are running at once, and I found no way to attach gdb to all of them at once. So I was hoping maybe I can cause CrashReporter to attach the debugger when specific process crashes – is there a way to do it?
Unfortunately, the type of bug you describe has a tendency to disappear when perturbed by examination.
That said, an option to try is launching a GDB session from inside your module. QA1573 has an example using DTrace, which would seem a bit cleaner, but after some experimentation this doesn’t seem to work terribly well with multiple processes. (I could not see a way to get DTrace to attach
gdbat the time the process crashes; you only get aproc::postsig:signal-handleprobe triggered after the process has already crashed.)You could do something like this from your module:
which would open a separate Terminal window for each
httpdprocess.You could also start
gdbfrom outside instead, with a script (DTrace or otherwise) watching forhttpdprocesses, and use theSIGSTOPmethod from QA1573 in your module’s code to wait until the script noticed the newhttpd.