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 gdb
at the time the process crashes; you only get a proc::postsig:signal-handle
probe triggered after the process has already crashed.)
You could do something like this from your module:
% echo 'c' > continue.txt
% osascript -e 'tell app "Terminal" to do script "gdb -x continue.txt attach <pid>"'
which would open a separate Terminal window for each httpd
process.
You could also start gdb
from outside instead, with a script (DTrace or otherwise) watching for httpd
processes, and use the SIGSTOP
method from QA1573 in your module's code to wait until the script noticed the new httpd
.
After few months, I guess we can say the answer is no, you can't. :)
To debug your problem, the crash report should be exploitable... but if really not, you might try to enable apache error log and also your own logging code. Then watching logs / console when a crash occurs should help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With