View Issue Details

IDProjectCategoryView StatusLast Update
0001916XdebugUncategorizedpublic2021-04-14 16:00
ReporterMr_What4 Assigned To 
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionunable to reproduce 
Product Version3.0.1 
Summary0001916: Seeing a Segfault with XDebug 3.0.1 and PHP 7.2 - 8.0
Description

When running PHPCS with xdebug installed and enabled is causing a segfault:

Starting program: /usr/lib64/php7.4/bin/php -f vendor/bin/phpcs -- -s --standard=phpcs.xml
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[Detaching after vfork from child process 28607]
[Detaching after vfork from child process 28609]

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff4c9b390 in ?? ()
(gdb) bt
#0 0x00007ffff4c9b390 in ?? ()
#1 0x0000555555921e7e in tsrm_shutdown () at /var/tmp/portage/dev-lang/php-7.4.13/work/sapis-build/cli/TSRM/TSRM.c:215
0000002 0x00005555556b5f41 in main (argc=6, argv=0x55555658a100) at /var/tmp/portage/dev-lang/php-7.4.13/work/sapis-build/cli/sapi/cli/php_cli.c:1380

This only seems to happen with XDebug 3.0.1, 2.9.8 seems to work as expected.

Steps To Reproduce

/usr/lib64/php7.4/bin/php -f vendor/bin/phpcs -- -s --standard=phpcs.xml

Additional Information

PHP version doesn't seem to matter, 7.4.13 was used for this backtrace.

squizlabs/php_codesniffer 3.5.8 PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.

My xdebug.ini:

zend_extension=/usr/lib64/php7.4/lib/extensions/no-debug-zts-20190902/xdebug.so
;xdebug.auto_trace = 0
;xdebug.cli_color = 0
;xdebug.collect_assignments = 0
;xdebug.collect_includes = 1
;xdebug.collect_params = 0
;xdebug.collect_return = 0
;xdebug.collect_vars = 0
;xdebug.coverage_enable = 1
xdebug.default_enable = 0
;xdebug.dump. = Empty
;xdebug.dump_globals = 1
;xdebug.dump_once = 1
;xdebug.dump_undefined = 0
;xdebug.extended_info = 1
;xdebug.file_link_format =
;xdebug.force_display_errors = 0
;xdebug.force_error_reporting = 0
;xdebug.halt_level = 0
;xdebug.idekey =
complex*
;xdebug.manual_url = http://www.php.net
;xdebug.max_nesting_level = 256
;xdebug.max_stack_frames = -1
;xdebug.overload_var_dump = 2
;xdebug.profiler_aggregate = 0
;xdebug.profiler_append = 0
;xdebug.profiler_enable = 0
;xdebug.profiler_enable_trigger = 0
;xdebug.profiler_enable_trigger_value = ""
;xdebug.profiler_output_dir = /tmp
;xdebug.profiler_output_name = cachegrind.out.%p
;xdebug.remote_addr_header = ""
;xdebug.remote_autostart = 0
;xdebug.remote_connect_back = 0
;xdebug.remote_cookie_expire_time = 3600
;xdebug.remote_enable = 0
;xdebug.remote_handler = dbgp
;xdebug.remote_host = localhost
;xdebug.remote_log =
;xdebug.remote_mode = req
;xdebug.remote_port = 9000
;xdebug.scream = 0
;xdebug.show_error_trace = 0
;xdebug.show_exception_trace = 0
;xdebug.show_local_vars = 0
;xdebug.show_mem_delta = 0
;xdebug.trace_enable_trigger = 0
;xdebug.trace_enable_trigger_value = ""
;xdebug.trace_format = 0
;xdebug.trace_options = 0
;xdebug.trace_output_dir = /tmp
;xdebug.trace_output_name = trace.%c
;xdebug.var_display_max_children = 128
;xdebug.var_display_max_data = 512
;xdebug.var_display_max_depth = 3

My phpcs.xml:

<?xml version="1.0"?>
<ruleset name="FaaPz PDO">
<description>Just another PDO database library</description>

<file>src/</file>
<file>tests/</file>

<!-- Include the whole PSR-1 standard -->
<rule ref="PSR1"/>

<!-- Include the whole PSR-2 standard -->
<rule ref="PSR2"/>

<!-- Include the whole PSR-12 standard -->
<rule ref="PSR12"/>

<!-- Include part of the Squiz standard -->
<rule ref="Squiz">
    <exclude name="Generic.Commenting.DocComment.ContentAfterClose"/>
    <exclude name="Generic.Commenting.DocComment.ContentAfterOpen"/>
    <exclude name="Generic.Commenting.DocComment.ContentBeforeClose"/>
    <exclude name="Generic.Commenting.DocComment.MissingShort"/>
    <exclude name="Generic.Formatting.MultipleStatementAlignment.NotSame"/>
    <exclude name="PEAR.Functions.FunctionCallSignature.CloseBracketLine"/>
    <exclude name="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket"/>
    <exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/>
    <exclude name="Squiz.Commenting.ClassComment.Missing"/>
    <exclude name="Squiz.Commenting.ClassComment.TagNotAllowed"/>
    <exclude name="Squiz.Commenting.ClosingDeclarationComment.Missing"/>
    <exclude name="Squiz.Commenting.FileComment.MissingAuthorTag"/>
    <exclude name="Squiz.Commenting.FileComment.MissingPackageTag"/>
    <exclude name="Squiz.Commenting.FileComment.MissingSubpackageTag"/>
    <exclude name="Squiz.Commenting.FileComment.PackageTagOrder"/>
    <exclude name="Squiz.Commenting.FileComment.SpacingAfterOpen"/>
    <exclude name="Squiz.Commenting.FileComment.SubpackageTagOrder"/>
    <exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/>
    <exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/>
    <exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/>
    <exclude name="Squiz.Commenting.FunctionComment.Missing"/>
    <exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/>
    <exclude name="Squiz.Commenting.LongConditionClosingComment.Missing"/>
    <exclude name="Squiz.Commenting.VariableComment.IncorrectVarType"/>
    <exclude name="Squiz.ControlStructures.ElseIfDeclaration.NotAllowed"/>
    <exclude name="Squiz.ControlStructures.SwitchDeclaration.BreakIndent"/>
    <exclude name="Squiz.ControlStructures.SwitchDeclaration.DefaultNoBreak"/>
    <exclude name="Squiz.Files.FileExtension.ClassFound"/>
    <exclude name="Squiz.Formatting.OperatorBracket.MissingBrackets"/>
    <exclude name="Squiz.Objects.ObjectInstantiation.NotAssigned"/>
    <exclude name="Squiz.Operators.ComparisonOperatorUsage.ImplicitTrue"/>
    <exclude name="Squiz.Operators.ComparisonOperatorUsage.NotAllowed"/>
    <exclude name="Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure"/>
    <exclude name="Squiz.Strings.ConcatenationSpacing.PaddingFound"/>
    <exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
    <exclude name="Squiz.WhiteSpace.FunctionClosingBraceSpace.SpacingBeforeClose"/>
    <exclude name="Squiz.WhiteSpace.FunctionSpacing.After"/>
    <exclude name="Squiz.WhiteSpace.FunctionSpacing.AfterLast"/>
    <exclude name="Squiz.WhiteSpace.FunctionSpacing.Before"/>
    <exclude name="Squiz.WhiteSpace.FunctionSpacing.BeforeFirst"/>
    <exclude name="Squiz.WhiteSpace.MemberVarSpacing.FirstIncorrect"/>
    <exclude name="Squiz.WhiteSpace.ObjectOperatorSpacing.Before"/>
</rule>

</ruleset>

TagsNo tags attached.
Operating System
PHP Version7.4.10-7.4.19

Activities

Mr_What4

2020-12-16 00:51

reporter   ~0005590

I put in the xdebug.ini from 2.9, here is my 3.0.1:

zend_extension=/usr/lib64/php7.4/lib/extensions/no-debug-zts-20190902/xdebug.so
;xdebug.cli_color = 0
;xdebug.client_discovery_header =
;xdebug.client_host = localhost
;xdebug.client_port = 9003
;xdebug.collect_params = 0
;xdebug.collect_return = 0
;xdebug.connect_timeout_ms = 200
;xdebug.discover_client_host = 0
;xdebug.dump. = Empty
;xdebug.dump_globals = 1
;xdebug.dump_once = 1
;xdebug.dump_undefined = 0
;xdebug.file_link_format =
;xdebug.filename_format = ...%s%n
;xdebug.force_display_errors = 0
;xdebug.force_error_reporting = 0
;xdebug.gc_stats_output_name = gcstats.%p
;xdebug.halt_level = 0
;xdebug.idekey =
complex*
;xdebug.log =
;xdebug.log_level = 7
;xdebug.max_nesting_level = 256
;xdebug.max_stack_frames = -1
xdebug.mode=off
;xdebug.output_dir = /tmp
;xdebug.profiler_append = 0
;xdebug.profiler_output_name = cachegrind.out.%p
;xdebug.scream = 0
;xdebug.show_error_trace = 0
;xdebug.show_exception_trace = 0
;xdebug.show_local_vars = 0
;xdebug.start_upon_error = default
;xdebug.start_with_request = default
;xdebug.trace_format = 0
;xdebug.trace_options = 0
;xdebug.trace_output_dir = /tmp
;xdebug.trace_output_name = trace.%c
;xdebug.trigger_value = ""
;xdebug.var_display_max_children = 128
;xdebug.var_display_max_data = 512
;xdebug.var_display_max_depth = 3

derick

2020-12-17 15:00

administrator   ~0005591

Can you provide the exact steps (git clone, composer install, etc) for me to try to reproduce this problem?

Mr_What4

2020-12-17 15:55

reporter   ~0005593

Hi Derick,

Thanks for taking a look at this. I am using gentoo AMD Ryzen 7 3700X 8-Core Processor, cflags = "-march=native -mtune=native -O2 -ftree-vectorize -fomit-frame-pointer -ggdb -pipe". Composer version: 1.10.15

The following produces two segfaults. First segfault happens on composer install and the second on phpcs. Seems to happen every time for me.

git clone git@github.com:FaaPz/PDO.git
composer install
vendor/bin/phpcs -s --standard=phpcs.xml

Mr_What4

2021-01-19 02:59

reporter   ~0005639

Problem still persists with xdebug 3.0.2

derick

2021-01-20 11:28

administrator   ~0005641

I have tried reproducing this (with xdebug 3.0.3-dev), but I am not getting any segfault, or any other warnings when running with valgrind like this either:

<code>
USE_ZEND_ALLOC=0 valgrind php -f vendor/bin/phpcs -- -s --standard=phpcs.xml
</code>

Your original backtrace doesn't show that Xdebug is involved in the crash either... So unless you can come up with something that allows me to see the problem locally, I am not sure what I can do.

Mr_What4

2021-01-25 16:22

reporter   ~0005659

This bug is the same as https://bugs.xdebug.org/view.php?id=1934, my best guess is xdebug is getting unloaded twice but I'll see if I can get a better trace in the other bug.

dinu

2021-02-03 13:04

reporter   ~0005665

I got a bunch of segfaults yesterday that started out as php errors, but were crashing fpm. I haven't investigated them but my best guess is Xdebug (call me grinch :D). Have you managed to reproduce it or should I try to rollback the code and see if I can generate a dump?

Mr_What4

2021-02-03 15:11

reporter   ~0005666

I can reproduce it every time I run php but my GDB skills are pretty poor. This segfault seems to be related to unloading the xdebug extension when ZTS is enabled. I suspect it is getting unloaded twice or this is some other type of race condition going on when PHP is cleaning itself up. If you have an idea about something I should try with GDB or anything else let me know. If I disable ZTS things do work normally.

My configuration:

./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --docdir=/usr/share/doc/php-7.4.14-r1 --htmldir=/usr/share/doc/php-7.4.14-r1/html --prefix=/usr/lib64/php7.4 --mandir=/usr/lib64/php7.4/man --infodir=/usr/lib64/php7.4/info --libdir=/usr/lib64/php7.4/lib --with-libdir=lib64 --localstatedir=/var --without-pear --enable-maintainer-zts --without-password-argon2 --enable-bcmath --with-bz2=/usr --disable-calendar --disable-gcov --enable-ctype --with-curl --enable-dom --without-enchant --disable-exif --without-ffi --enable-fileinfo --enable-filter --enable-ftp --with-gettext=/usr --without-gmp --without-mhash --with-iconv --disable-intl --disable-ipv6 --enable-json --without-kerberos --with-libxml --enable-mbstring --with-openssl --enable-pcntl --enable-phar --enable-pdo --enable-opcache --without-pgsql --enable-posix --with-pspell=/usr --enable-simplexml --disable-shmop --without-snmp --enable-soap --enable-sockets --without-sodium --with-sqlite3 --enable-sysvmsg --enable-sysvsem --enable-sysvshm --without-tidy --enable-tokenizer --enable-xml --disable-xmlreader --enable-xmlwriter --without-xmlrpc --without-xsl --with-zip --with-zlib=/usr --disable-debug --enable-dba --without-cdb --with-db4=/usr --enable-flatfile --with-gdbm=/usr --disable-inifile --without-qdbm --without-tcadb --without-lmdb --without-freetype --disable-gd-jis-conv --without-jpeg --without-xpm --without-webp --disable-gd --without-mysqli --with-mysql-sock=/var/run/mysqld/mysqld.sock --without-unixODBC --without-iodbc --without-pdo-odbc --without-oci8 --without-pdo-dblib --with-pdo-mysql=mysqlnd --without-pdo-pgsql --with-pdo-sqlite --without-pdo-firebird --without-pdo-oci --with-readline=/usr --without-libedit --without-mm --with-pic --with-external-pcre --without-pcre-jit --cache-file=/var/tmp/portage/dev-lang/php-7.4.14-r1/temp/config.cache --with-config-file-path=/etc/php/cli-php7.4 --with-config-file-scan-dir=/etc/php/cli-php7.4/ext-active --disable-embed --enable-cli --disable-cgi --disable-fpm --without-apxs2 --disable-phpdbg

catalin.nicolescu

2021-02-15 07:28

reporter   ~0005667

Confirming this. Using the docker image 7.3-apache-stretch with "pecl install xdebug" and XDEBUG_MODE="develop,debug" XDEBUG_CONFIG="cli_color=1 client_host=192.168.64.1 client_port=9000 discover_client_host=0 start_with_request=1"
Seeing segmentation faults on random phpunit tests
Had to revert back to 2.9.8

BitWire

2021-02-19 16:26

reporter   ~0005691

I can reproduce this error in a docker container running php7.3 & xdebug 3.0.2. Random tests are failing, depending if i call phpunit with or without --testdox. It only happens with xdebug.mode=develop. every other mode is fine, and every combination without develop is fine.
I attached a gdb stacktrace.

vincent

2021-03-02 09:58

reporter   ~0005699

Same issue on a private repository (can't provide source code to reproduce)
Random segfault when execute phpunit tests on our dev docker container (with xDebug)
Work fine with our production container (without xDebug)

PHP 8.0.0 (cli) (built: Dec 1 2020 03:33:03) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
with Zend OPcache v8.0.0, Copyright (c), by Zend Technologies
with Xdebug v3.0.3, Copyright (c) 2002-2021, by Derick Rethans

[Xdebug]
xdebug.max_nesting_level = 1000
xdebug.remote_enable=On
xdebug.remote_port=9500
xdebug.remote_connect_back=On
xdebug.idekey=PHPSTORM
xdebug.remote_host=localhost
xdebug.cli_color=1
xdebug.var_display_max_depth=10

Mr_What4

2021-03-03 06:39

reporter   ~0005700

Hi Derick,

I have tracked the issue to --disable-debug configuration. If it is disabled, it crashes for me every time with php -v and xdebug 3.0.x. I am not sure why this is the case as I can't really get a good stack trace without --enable -debug but hopefully this can help reproduce the issue.

derick

2021-03-03 11:43

administrator   ~0005702

Hi,

I've just tried reproducing this again, but it still does not produce any crashes, or valgrind errors with php 7.4.13 in non-debug mode, and Xdebug also not compiled in debug mode. Perhaps this is a compiler or libc inconsistency, but as long as I can't reproduce this... I'm going to be in the dark.

If somebody can manage to create a docker setup, where I can ssh-in and run a PHP CLI command, and where also gdb, valgrind, and strace are installed, I can give that a go.

cheers,
Derick

derick

2021-03-17 08:21

administrator   ~0005716

Unless I get the requested additional information, I will be closing this report in the next week or so.

derick

2021-04-14 16:00

administrator   ~0005827

Closing this, as I can't either reproduce this, or not enough information has been provided, even after soliciting feedback again.