Description | PHP-FPM crashes when Xdebug tries to write "The setting 'xdebug.remote_enable' has been renamed" error to the logs, if the "xdebug.remote_enable" ini setting is coming from a user.ini file in the webservers document root.
PHP versions affected: PHP 7.2, 7.3, 7.4 and 8.0
Webservers affected: both nginx and Apache
The issue looks like this:
[ 89.757961] traps: php-fpm7.4[1208] general protection fault ip:7ff3ad7626ec sp:7ffea5196388 error:0 in libc-2.31.so[7ff3ad5f9000+178000]
[ 94.470969] traps: php-fpm7.4[1209] general protection fault ip:7ff3ad7626ec sp:7ffea5196388 error:0 in libc-2.31.so[7ff3ad5f9000+178000]
[ 178.927980] traps: php-fpm7.4[29914] general protection fault ip:7ff3ad7626ec sp:7ffea5196388 error:0 in libc-2.31.so[7ff3ad5f9000+178000]
[ 791.198288] traps: php-fpm7.4[30735] general protection fault ip:7f698d9eb6ec sp:7ffc23880f98 error:0 in libc-2.31.so[7f698d882000+178000]
[ 2522.739233] traps: php-fpm7.4[32833] general protection fault ip:7f39a06566ec sp:7ffefefc4de8 error:0 in libc-2.31.so[7f39a04ed000+178000]
[ 3735.619523] traps: php-fpm7.4[34451] general protection fault ip:7f9b0bb766ec sp:7fffcc8eb6b8 error:0 in libc-2.31.so[7f9b0ba0d000+178000]
[ 4068.876084] traps: php-fpm7.4[34452] general protection fault ip:7f9b0ba80a2f sp:7fffcc8eba30 error:0 in libc-2.31.so[7f9b0ba0d000+178000]
[ 4073.051640] traps: php-fpm7.4[34464] general protection fault ip:7f9b0bb766ec sp:7fffcc8eb6b8 error:0 in libc-2.31.so[7f9b0ba0d000+178000]
[ 4167.418762] traps: php-fpm7.4[34801] general protection fault ip:7f9b0bb766ec sp:7fffcc8eb6b8 error:0 in libc-2.31.so[7f9b0ba0d000+178000]
[ 5369.499371] traps: php-fpm7.4[34804] general protection fault ip:7f9b0ba80a2f sp:7fffcc8eba30 error:0 in libc-2.31.so[7f9b0ba0d000+178000]
The backtrace looks like this:
Program terminated with signal SIGSEGV, Segmentation fault.
#0 memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:306
306 ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.
(gdb) bt
#0 memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:306
#1 0x00007f8b3dc59257 in memcpy (len=18, src=0x7f8b3dc7da89, dest=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:34
0000002 xdebug_str_internal_addl (f=0, le=18, str=0x7f8b3dc7da89 "<tr><td class=\"i\">", xs=0x5607f784dbc0) at ./build-7.4/src/lib/str.c:46
0000003 xdebug_str_addl (xs=0x5607f784dbc0, str=str@entry=0x7f8b3dc7da89 "<tr><td class=\"i\">", le=le@entry=18, f=f@entry=0) at ./build-7.4/src/lib/str.c:62
0000004 0x00007f8b3dc57d98 in xdebug_diagnostic_log (
message=0x7fff083cdf50 "The setting 'xdebug.remote_enable' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_enable",
error_code=0x7f8b3dc7b051 "CHANGED", log_level=0, channel=0) at ./build-7.4/src/lib/log.c:101
0000005 xdebug_log_ex (channel=channel@entry=0, log_level=log_level@entry=0, error_code=error_code@entry=0x7f8b3dc7b051 "CHANGED",
fmt=fmt@entry=0x7f8b3dc7bb68 "The setting '%s' has been renamed, see the upgrading guide at %supgrade_guide#changed-%s") at ./build-7.4/src/lib/log.c:164
0000006 0x00007f8b3dc503a4 in OnUpdateChangedSetting (new_value=<optimized out>, mh_arg1=<optimized out>, mh_arg2=<optimized out>, mh_arg3=<optimized out>, stage=<optimized out>,
entry=0x5607f7837b00) at ./build-7.4/xdebug.c:208
0000007 OnUpdateChangedSetting (entry=0x5607f7837b00, new_value=<optimized out>, mh_arg1=<optimized out>, mh_arg2=<optimized out>, mh_arg3=<optimized out>, stage=<optimized out>)
at ./build-7.4/xdebug.c:202
0000008 0x00005607f5b61291 in zend_alter_ini_entry_ex ()
0000009 0x00005607f5aedc7b in php_ini_activate_config ()
0000010 0x00005607f5bdc837 in ?? ()
0000011 0x00005607f5aeea6c in sapi_activate ()
0000012 0x00005607f5ae556e in php_request_startup ()
0000013 0x00005607f59ae9a9 in ?? ()
0000014 0x00007f8b3fdd30b3 in libc_start_main (main=0x5607f59adaf0, argc=4, argv=0x7fff083cebd8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff083cebc8)
at ../csu/libc-start.c:308
0000015 0x00005607f59af81e in _start () |
---|
Steps To Reproduce |
- Set up Apache or Nginx with PHP-FPM on Ubuntu Linux 20.04 LTS with PHP 7.2 or later. (PHP 7.1 or earlier is not effected.)
- Create a simple php file in the webserver's document root, e.g.: index.php containing
<?php phpinfo(); .
- Create an
user.ini file in the webserver's document root and put an Xdebug ini setting in it for Xdebug version 2, e.g.: xdebug.remote_enable=true
- Important that if there is a persistent php-fpm process it must be restarted or it must be started AFTER the user.ini is created, e.g.:
sudo service php7.4-fpm restart .
- Open the site being served by the webserver, and reload the page a few times.
Approximately in 60% of the cases the server responds with 502 Bad Gateway or similar error and for each such response php-fpn crashes with the above included trace.
I have been able to consistently reproduce the issue but only if php-fpm is restarted after the user.ini is added. If the user.ini is added while php-fpm is running, no issues appear at all. |
---|
Additional Information | If the Xdebug v2 settings are added to the on-server php ini files, there is no problem. The issue only happens if Xdebug attempts to write the "The setting '...' has been renamed" error message when the user.ini is loaded from the document root on a fresh php-fpm process.
This issue has been found in a Vagrant box based on Laravel Homested. This is not that much interesting, but it may provide a convenient way to reproduce the issue, since vagrant can be used to reproduce the exact environment where the issue is happening.
https://github.com/laravel/homestead/issues/1654 |
---|