my life

day to day

PHP Segfault Backtraces

September 21st, 2006

Got some excellent advice today on bug hunting PHP segfaults from Brian Shire. You can use GDB to inspect php internal variables to produce a readable backtrace that looks something like

(gdb) zbacktrace [0xbfec1c84] unsetMap() /path/CometSimulatorServer.class.php:144 [0xbfec21b4] unsetMap() /path/CometSimulatorAssistant.class.php:153 [0xbfec23d4] merge() /path/CometSimulatorMerge.class.php:34 [0xbfec2478] process() [0xbfec2704] call_user_func_array() /path/CometPacket.class.php:81 [0xbfec2bf4] process() /path/PacketHandler.class.php:77 [0xbfec3334] process() /path/MessagePump.class.php:84 [0xbfec35e4] recv() /path/MessagePump.class.php:56 [0xbfec3ab4] task() /path/Event.class.php:190 [0xbfec4414] run() /path/LoopScheduler.class.php:113 [0xbfec5354] dispatch() /path/cometd.php:161

Basic process
ulimit -c unlimited  # run your script

gdb /path/to/php/binary -c [corefile] -x [debug-script]

gdb debug functions

http://viewcvs.php.net/viewvc.cgi/php-src/.gdbinit?view=co

add to del.icio.us    add to technorati favs    email this

Leave a Reply