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
Hanging Off A Branch
I have seen Great Spotted Woodpeckers at the Isabella Plantation in Richmond Park before, but this one was elusive.
I first heard it tap, and saw some glimpses of it scooting away. It was then high up a tree, out of good light and sight before I lost track of it.
I turned around and it was then just there above me, hanging upside down gorging on seeds.
#photography #Birds #BirdPhotography #BirdsOfFediverse #NaturePhotography #wildlife #london #RichmondPark
Staring Me Down
This lovely stag was keeping a keen eye on me walking past in Richmond Park. A lovely day out, but very few birds. Hoping c2c gets their railway sorted soon so I can get to Rainham again.
Grey Wagtail Forraging
This one is often shows around at the Ken Barratt Hide at RSPB Rainham Marshes.
#photography #Birds #BirdPhotography #BirdsOfFediverse #NaturePhotography #wildlife #RSPB #RainhamMarshes
Updated a pub
Updated a toilet; Deleted a toilet
I hiked 16.2km in 5h12m16s
Mary Had Two Little Lambs
#photography #SheepOfMastodon #Defaidodon #DyddDefaidodon #DefaidodonDay
Just Relaxing While Mom Makes Milk
#photography #SheepOfMastodon #Defaidodon #DyddDefaidodon #DefaidodonDay
Grazing on the Cliff Edge
#photography #SheepOfMastodon #Defaidodon #DyddDefaidodon #DefaidodonDay #shetland
I walked 3.7km in 1h15m13s
Survey housenumbers
Specify whether there are cycleways
Specify whether roads have sidewalks
New layout
I walked 7.9km in 1h34m09s
Little Egret Looking Sharp
I always like looking at these birds. They move so gracefully, but are also fun to see catch fish.
#photography #Birds #BirdPhotography #BirdsOfFediverse #NaturePhotography #wildlife #wwt #london
Updated an entrance
I walked 9.1km in 1h44m35s
Iridescent Colours
This Lapwing, one of about a hundred in the flock, nicely stopped to pose for me. The sun was getting lower making its wings shine in iridescent colours. In winter many flock together here at the London Wetland Centre.
#photography #Birds #BirdPhotography #BirdsOfFediverse #NaturePhotography #wildlife #wwt #london
Go with 2026.03
Merged pull request #189
Survey hairdresser's customers












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