PHP's segmentation faults GDB-fu
Sometimes PHP segfaults (crashes) in a production environment, where Xdebug is often not available (and shouldn't be either of course). In those cases trying to figure out where in your code PHP crashes can be hard to find out. In some cases it's a real bug in PHP, where you would need some more intricate knowledge of PHP's internals — in many cases it's rather a coding error that provides you with infinite recursion.
Trying to figure out the functions that were called in a loop is not trivial if you do not possess GDB- and PHP internals-fu. However, because we as PHP developers are lazy, provide a few GDB tricks to make this easier. First of all, it's only really going to work if you haven't stripped the symbols from your PHP and Apache binaries. Secondly, you still need to have the PHP source lying around somewhere — preferably from where you've built PHP. After you're in GDB (either by opening an already existing core dump, or when the process aborts after starting it from GDB) you can "source" the macros that make your life easier. Basically you have to run this on the GDB prompt:
(gdb) source ~/dev/php/php-5.2dev/.gdbinit
If you then run the following on the GDB prompt, you get a nice stack trace — but without variable information that you're used to from seeing Xdebug traces.
(gdb) zbacktrace
The start of the output looks like:
[0xd03bb330] a() /tmp/recur.php:5 [0xd03bb530] d() /tmp/recur.php:4 [0xd03bb730] c() /tmp/recur.php:3 [0xd03bb930] b() /tmp/recur.php:2 ...
In PHP 5.3 and higher, PHP will not segfault when you do infinite recursion as the engine has been changed. Instead, PHP would simply run out of memory and show an error not unlike:
Fatal error: Allowed memory size of 134217728 bytes exhausted at /home/derick/dev/php/php-5.3dev/Zend/zend_execute.h:157 (tried to allocate 523800 bytes) in /tmp/recur.php on line 2
Update: Instead of "dump_bt executor_globals.current_execute_data" you can simply run "zbacktrace".
Life Line
I walked 3.5km in 35m31s
Created a main entrance and a home entrance
Created an entrance
Updated a house building
Created an entrance
I walked 5.8km in 1h15m06s
I've just finished reading "A Cheese-Monger's Tour de France", by Ned Palmer.
Now I want to try many of those! 🧀
I'm thrilled to announce that I'll be speaking at the 23rd edition of #phpday, the international PHP conference in Italy, organised by @grusp.
I’ll be presenting a talk titled: "Better Debugging With Xdebug".
It's in Verona, Italy, on May 14-15th 2026.
You can use my speaker’s discount code "speaker_10OFF" for 10% off at https://www.phpday.it/tickets/?utm_medium=organic&utm_source=linkedin&utm_campaign=post-speaker
I walked 5.5km in 1h11m00s
I walked 1.1km in 9m37s
Merged pull request #1066
PHP 8.6: Changes to opcache optimisations wrt function arguments
I walked 10.5km in 1h49m54s
Fixed building type
Fixed addresses and building type
Updated a bus_stop, a waste_basket, and a bench
Created 2 waste_baskets; Updated 2 bus_stops and a crossing; Confirmed a dry_cleaning shop
I walked 8.5km in 1h29m59s
Merge branch 'v2022'
Update data to 2026a
I walked 5.6km in 1h8m16s
I walked 9.5km in 2h15m36s
Sigh, the AI Slop has now come for the PHP project.
I had this little Black-capped Chickadee eating out of my hand earlier on a lovely 8k walk with @dseguy and @DaveLiddament in the snow at the back end of @ConFooCa .
Thanks Canada!
Updated a restaurant



Shortlink
This article has a short URL available: https://drck.me/psfg-6ho