php / php-src

The PHP Interpreter
https://www.php.net
Other
38.19k stars 7.75k forks source link

PHP CLI with Symfony causing Program received signal SIGSEGV, Segmentation fault #9360

Closed kellyjoe256 closed 2 years ago

kellyjoe256 commented 2 years ago

Description

I have been doing a simple study into the api-platform. Until today, everything was working fine, but then I upgraded the packages on my computer by running

sudo apt-get update && sudo apt-get upgrade

The upgrade also happened to update my php as seen below from running the command cat /var/log/apt/history.log

Start-Date: 2022-08-17  09:59:11
Commandline: apt-get upgrade
Requested-By: mayatsa (1000)
Upgrade: php8.1-intl:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), php8.1-mysql:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), tracker-extract:amd64 (2.3.3-2, 2.3.3-2ubuntu0.20.04.1), python3-dnspython:amd64 (1.16.0-1build1, 1.16.0-1ubuntu1), php-xdebug:amd64 (3.1.2+2.9.8+2.8.1+2.5.5-4+ubuntu20.04.1+deb.sury.org+10, 3.1.5+2.9.8+2.8.1+2.5.5-1+ubuntu20.04.1+deb.sury.org+1), php8.1-xml:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), php8.1-zip:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), php8.1-common:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), libsnmp-base:amd64 (5.8+dfsg-2ubuntu2.4, 5.8+dfsg-2ubuntu2.5), php8.1:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), google-chrome-stable:amd64 (104.0.5112.79-1, 104.0.5112.101-1), nodejs:amd64 (16.16.0-deb-1nodesource1, 16.17.0-deb-1nodesource1), php8.1-xdebug:amd64 (3.1.2+2.9.8+2.8.1+2.5.5-4+ubuntu20.04.1+deb.sury.org+10, 3.1.5+2.9.8+2.8.1+2.5.5-1+ubuntu20.04.1+deb.sury.org+1), tracker-miner-fs:amd64 (2.3.3-2, 2.3.3-2ubuntu0.20.04.1), libsnmp35:amd64 (5.8+dfsg-2ubuntu2.4, 5.8+dfsg-2ubuntu2.5), php8.1-sqlite3:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), php8.1-mbstring:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), php8.1-readline:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), php8.1-opcache:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), libwebkit2gtk-4.0-37:amd64 (2.36.4-0ubuntu0.20.04.1, 2.36.6-0ubuntu0.20.04.1), php8.1-pgsql:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), php8.1-cli:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), php8.1-fpm:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), gir1.2-webkit2-4.0:amd64 (2.36.4-0ubuntu0.20.04.1, 2.36.6-0ubuntu0.20.04.1), php8.1-gd:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), php8.1-curl:amd64 (8.1.8-1+ubuntu20.04.1+deb.sury.org+1, 8.1.9-1+ubuntu20.04.1+deb.sury.org+1), libjavascriptcoregtk-4.0-18:amd64 (2.36.4-0ubuntu0.20.04.1, 2.36.6-0ubuntu0.20.04.1), gir1.2-javascriptcoregtk-4.0:amd64 (2.36.4-0ubuntu0.20.04.1, 2.36.6-0ubuntu0.20.04.1)
End-Date: 2022-08-17  10:00:01

Currently, my php version is as follows

PHP 8.1.9 (cli) (built: Aug 15 2022 09:39:52) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.9, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.9, Copyright (c), by Zend Technologies
    with Xdebug v3.1.5, Copyright (c) 2002-2022, by Derick Rethans

Now, when I run my the command symfony console list at the root of symfony project I get

signal: segmentation fault (core dumped)

Thanks to this question, I was able to run this command gdb $(which php8.1) and then I typed run [project_path]/bin/console and got

Starting program: /usr/bin/php8.1 [project_path]/bin/console
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
__memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:384
384 ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.

And here is the backtrace

#0  __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:384
#1  0x00007ffff568496c in memcpy (__len=18446744072874576453, __src=0x7ffaf6c00018, __dest=<optimized out>)
    at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:34
#2  xdebug_str_internal_addl (f=0, le=<optimized out>, 
    str=0x7ffaf6c00018 "\\nSymfony\\\\Component\\\\DependencyInjection\\\\Exception\\\\RuntimeException: Invalid reference. in /home/mayatsa/Documents/study/php/symfony/api-platform/vendor/symfony/dependency-injection/Compiler/Resolv"..., xs=0x555556679f90) at ./build-8.1/src/lib/str.c:44
#3  xdebug_str_add_zstr (xs=xs@entry=0x555556679f90, str=str@entry=0x7ffaf6c00000) at ./build-8.1/src/lib/str.c:70
#4  0x00007ffff5689110 in xdebug_var_export_line (struc=struc@entry=0x7fffffff8c60, str=str@entry=0x555556679f90, level=level@entry=15, 
    debug_zval=debug_zval@entry=0, options=options@entry=0x555555eddeb0) at ./build-8.1/src/lib/var_export_line.c:225
#5  0x00007ffff56894dd in xdebug_object_element_export (class_name=<optimized out>, options=0x555555eddeb0, debug_zval=0, str=0x555556679f90, level=13, 
    hash_key=<optimized out>, index_key=<optimized out>, zv_nptr=<optimized out>, object=<optimized out>) at ./build-8.1/src/lib/var_export_line.c:104
#6  xdebug_var_export_line (struc=0x7fffffff8c58, struc@entry=0x7fffffff8d00, str=str@entry=0x555556679f90, level=level@entry=13, 
    debug_zval=debug_zval@entry=0, options=options@entry=0x555555eddeb0) at ./build-8.1/src/lib/var_export_line.c:317
#7  0x00007ffff56894dd in xdebug_object_element_export (class_name=<optimized out>, options=0x555555eddeb0, debug_zval=0, str=0x555556679f90, level=11, 
    hash_key=<optimized out>, index_key=<optimized out>, zv_nptr=<optimized out>, object=<optimized out>) at ./build-8.1/src/lib/var_export_line.c:104
#8  xdebug_var_export_line (struc=struc@entry=0x7fffffff8db0, str=str@entry=0x555556679f90, level=level@entry=11, debug_zval=debug_zval@entry=0, 
    options=options@entry=0x555555eddeb0) at ./build-8.1/src/lib/var_export_line.c:317
#9  0x00007ffff5688f6c in xdebug_array_element_export (options=0x555555eddeb0, debug_zval=0, str=0x555556679f90, level=9, hash_key=<optimized out>, 
    index_key=<optimized out>, zv_nptr=<optimized out>) at ./build-8.1/src/lib/var_export_line.c:52
#10 xdebug_var_export_line (struc=<optimized out>, struc@entry=0x7fffffff8e50, str=str@entry=0x555556679f90, level=level@entry=9, 
    debug_zval=debug_zval@entry=0, options=options@entry=0x555555eddeb0) at ./build-8.1/src/lib/var_export_line.c:249
#11 0x00007ffff5688f6c in xdebug_array_element_export (options=0x555555eddeb0, debug_zval=0, str=0x555556679f90, level=7, hash_key=<optimized out>, 
    index_key=<optimized out>, zv_nptr=<optimized out>) at ./build-8.1/src/lib/var_export_line.c:52
#12 xdebug_var_export_line (struc=<optimized out>, struc@entry=0x7fffffff8ee0, str=str@entry=0x555556679f90, level=level@entry=7, 
    debug_zval=debug_zval@entry=0, options=options@entry=0x555555eddeb0) at ./build-8.1/src/lib/var_export_line.c:249
#13 0x00007ffff56894dd in xdebug_object_element_export (class_name=<optimized out>, options=0x555555eddeb0, debug_zval=0, str=0x555556679f90, level=5, 
    hash_key=<optimized out>, index_key=<optimized out>, zv_nptr=<optimized out>, object=<optimized out>) at ./build-8.1/src/lib/var_export_line.c:104
#14 xdebug_var_export_line (struc=0x7fffffff8ed8, struc@entry=0x7fffffff8f80, str=str@entry=0x555556679f90, level=level@entry=5, 
    debug_zval=debug_zval@entry=0, options=options@entry=0x555555eddeb0) at ./build-8.1/src/lib/var_export_line.c:317
#15 0x00007ffff56894dd in xdebug_object_element_export (class_name=<optimized out>, options=0x555555eddeb0, debug_zval=0, str=0x555556679f90, level=3, 
    hash_key=<optimized out>, index_key=<optimized out>, zv_nptr=<optimized out>, object=<optimized out>) at ./build-8.1/src/lib/var_export_line.c:104
#16 xdebug_var_export_line (struc=0x7fffffff8f78, struc@entry=0x7fffffff9020, str=str@entry=0x555556679f90, level=level@entry=3, 
    debug_zval=debug_zval@entry=0, options=options@entry=0x555555eddeb0) at ./build-8.1/src/lib/var_export_line.c:317
#17 0x00007ffff56894dd in xdebug_object_element_export (class_name=<optimized out>, options=0x555555eddeb0, debug_zval=0, str=0x555556679f90, level=1, 
    hash_key=<optimized out>, index_key=<optimized out>, zv_nptr=<optimized out>, object=<optimized out>) at ./build-8.1/src/lib/var_export_line.c:104
#18 xdebug_var_export_line (struc=struc@entry=0x7fffffff9088, str=str@entry=0x555556679f90, level=level@entry=1, debug_zval=debug_zval@entry=0, 
    options=options@entry=0x555555eddeb0) at ./build-8.1/src/lib/var_export_line.c:317
#19 0x00007ffff56896a0 in xdebug_get_zval_value_line (val=<optimized out>, debug_zval=0, options=0x555555eddeb0) at ./build-8.1/src/lib/var_export_line.c:373
#20 0x00007ffff56a0d75 in add_single_value (html=<optimized out>, zv=<optimized out>, str=0x7fffffff9170) at ./build-8.1/src/develop/stack.c:263
--Type <RET> for more, q to quit, c to continue without paging-- c
#21 xdebug_append_printable_stack (str=str@entry=0x7fffffff9170, html=<optimized out>) at ./build-8.1/src/develop/stack.c:443
#22 0x00007ffff56a1be2 in xdebug_develop_throw_exception_hook (exception=exception@entry=0x7ffff0c1c320, file=file@entry=0x7ffff0c1c378, line=line@entry=0x7ffff0c1c388, code=code@entry=0x7ffff0c1c368, code_str=code_str@entry=0x0, message=message@entry=0x7ffff0c1c348) at ./build-8.1/src/develop/stack.c:989
#23 0x00007ffff567b757 in xdebug_throw_exception_hook (exception=0x7ffff0c1c320) at ./build-8.1/src/base/base.c:1381
#24 xdebug_throw_exception_hook (exception=0x7ffff0c1c320) at ./build-8.1/src/base/base.c:1324
#25 0x0000555555670e7c in zend_throw_exception_internal ()
#26 0x0000555555668d6e in ?? ()
#27 0x00005555558a1b71 in execute_ex ()
#28 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff5419160) at ./build-8.1/src/base/base.c:779
#29 0x00005555558a9062 in execute_ex ()
#30 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff5418a10) at ./build-8.1/src/base/base.c:779
#31 0x00005555558a9062 in execute_ex ()
#32 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff54183c0) at ./build-8.1/src/base/base.c:779
#33 0x00005555558a9062 in execute_ex ()
#34 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff5417d70) at ./build-8.1/src/base/base.c:779
#35 0x00005555558a9062 in execute_ex ()
#36 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff54176a0) at ./build-8.1/src/base/base.c:779
#37 0x00005555558a9f05 in execute_ex ()
#38 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff5417570) at ./build-8.1/src/base/base.c:779
#39 0x00005555558a9f05 in execute_ex ()
#40 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff5417320) at ./build-8.1/src/base/base.c:779
#41 0x00005555558a9f05 in execute_ex ()
#42 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff5416f90) at ./build-8.1/src/base/base.c:779
#43 0x00005555558a9f05 in execute_ex ()
#44 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff54163d0) at ./build-8.1/src/base/base.c:779
#45 0x00005555558a9f05 in execute_ex ()
#46 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff5416120) at ./build-8.1/src/base/base.c:779
#47 0x00005555558a9f05 in execute_ex ()
#48 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff5415f50) at ./build-8.1/src/base/base.c:779
#49 0x00005555558a9f05 in execute_ex ()
#50 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff5415cc0) at ./build-8.1/src/base/base.c:779
#51 0x00005555558a9f05 in execute_ex ()
#52 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff5415bd0) at ./build-8.1/src/base/base.c:779
#53 0x00005555558a9062 in execute_ex ()
#54 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff54156f0) at ./build-8.1/src/base/base.c:779
#55 0x00005555558a9062 in execute_ex ()
#56 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff54154d0) at ./build-8.1/src/base/base.c:779
#57 0x00005555558a9062 in execute_ex ()
#58 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff5415110) at ./build-8.1/src/base/base.c:779
#59 0x000055555587b02c in ?? ()
#60 0x00005555558a1397 in execute_ex ()
#61 0x00007ffff567cb72 in xdebug_execute_ex (execute_data=0x7ffff5415020) at ./build-8.1/src/base/base.c:779
#62 0x00005555558aa70d in zend_execute ()
#63 0x000055555583abb5 in zend_execute_scripts ()
#64 0x00005555557d7b9a in php_execute_script ()
#65 0x00005555559230fe in ?? ()
#66 0x0000555555679e78 in ?? ()
#67 0x00007ffff7631083 in __libc_start_main (main=0x555555679a70, argc=2, argv=0x7fffffffde38, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffde28) at ../csu/libc-start.c:308
#68 0x000055555567a64e in _start ()

I am no C or C++ developer, so I am not sure what the error means exactly, apart from No such file or directory part.

I would appreciate any help here. Thank you

PHP Version

PHP 8.1.9

Operating System

Ubuntu 20.04

damianwadley commented 2 years ago

Looks like an Xdebug issue. Try with that extension disabled.

@derickr ?

iluuu1994 commented 2 years ago

@kellyjoe256 The problem seems to occur in xdebug_str_internal_addl. Can you try without Xdebug? If the problem disappears report the problem at https://bugs.xdebug.org.

kellyjoe256 commented 2 years ago

Thank you, @damianwadley and @iluuu1994, it seems the issue was being caused by xdebug.

After disabling it, everything is working fine again. I am going to report the problem to the xdebug team.

derickr commented 2 years ago

FWIW, the Xdebug bug report is not useful, as it does not include a reproducible case.