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
Merged pull request #1029
Reflow some comments
Add comments, add end of file newlines, fix php 8.5 compilation
Benchmark Xdebug performance
Merged pull request #1051
PHP 8.6: printf() is now optimised out if it only uses %s and %d (and…
PHP 8.6: The object IDs of objects changed in tests
PHP 8.6: ZSTR_INIT_LITERAL() no longer takes non-literals, so use zen…
PHP 8.6: WRONG_PARAM_COUNT has been removed in favour of zend_wrong_p…
PHP 8.6: zval_dtor() has been deprecated in favour of zval_ptr_dtor_n…
Update test for version constraints, as well as the error messages
I walked 7.4km in 1h38m15s
I just watched an interesting and lovely documentary on BBC Four: The Magical World of Moss.
It's on the iPlayer for another month:
https://www.bbc.co.uk/programmes/m001hqthI walked 8.2km in 1h26m34s
Merge branch 'xdebug_3_5'
Document to use PIE instead of PECL in the README
I walked 9.2km in 1h45m44s
I walked 10.1km in 1h40m23s
If we must show off a little…
In more info innocent times, the hat riots caused some spankings...
100 Years Ago Men and Boys Fought on the Streets of New York Over Wearing Straw Hats Past Summer | The New York Public Library
https://www.nypl.org/blog/2022/09/23/straw-hat-riots-nyc


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