View Issue Details

IDProjectCategoryView StatusLast Update
0001313XdebugUncategorizedpublic2016-12-17 15:35
Reporterstringerbell Assigned Toderick  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
Platform86_64 x86_64 x86_64 GNU/LinuxOSCentOSOS Version6.7
Product Version2.4.0 
Target Version2.5.1Fixed in Version2.5.1 
Summary0001313: Segfault on centos when xdebug.collect_params != 1
Description

I'm getting a segfault when running phpspec. I initially thought this was a PHP or phpspec problem, but after uninstalling, and reinstalling PHP, I noticed my xdebug install settings were missing. After adding them back one by one, I was able to consistently get PHP to segfault when using xdebug.collect_params = 1.

My full settings are

[xdebug]
xdebug.remote_enable = 1
xdebug.remote_connect_back = 0
xdebug.remote_handler = dbgp
xdebug.remote_port = 9000
xdebug.remote_mode = req
xdebug.collect_params = 1
xdebug.remote_host = 192.168.33.1
xdebug.remote_log = /tmp/xdebug.log
xdebug.idekey = PHPSTORM
xdebug.var_display_max_depth = 10

Steps To Reproduce
  1. PHP 7.0.7 with Xdebug 2.4.0

(minimal repro case)

  1. https://github.com/phpspec/phpspec/issues/890#issuecomment-201492582
  2. run phpspec run
Additional Information

Backtrace with gdb (sorry I'm unsure which bits are relevant, but I'm happy to provide more info as needed):

#0 0x00007f3c9e8866bf in __strlen_sse42 () from /lib64/libc.so.6
#1 0x0000000000a1e0f7 in format_converter (odp=0x7ffcc428b420,
fmt=0x7f3c94f661b4 "s", ap=0x7ffcc428b4b0)
at /home/vagrant/src/php-src/main/snprintf.c:993
0000002 0x0000000000a1e9fa in strx_printv (ccp=0x7ffcc428b47c, buf=0x18dd090 "",
len=1, format=0x7f3c94f661ad "class %s", ap=0x7ffcc428b4b0)
at /home/vagrant/src/php-src/main/snprintf.c:1248
0000003 0x0000000000a1ecda in ap_php_vsnprintf (buf=0x18dd090 "", len=1,
format=0x7f3c94f661ad "class %s", ap=0x7ffcc428b4b0)
at /home/vagrant/src/php-src/main/snprintf.c:1303
0000004 0x00007f3c94f4d987 in xdebug_sprintf (fmt=0x7f3c94f661ad "class %s")
at /home/vagrant/src/xdebug-2.4.0/xdebug_str.c:97
0000005 0x00007f3c94f54ae6 in xdebug_var_synopsis (struc=0x7ffcc428b618,
str=0x7ffcc428b620, level=1, debug_zval=0, options=0x18dfae0)
at /home/vagrant/src/xdebug-2.4.0/xdebug_var.c:1244
0000006 0x00007f3c94f54c1a in xdebug_get_zval_synopsis (val=0x7f3c9b0182d0,
debug_zval=0, options=0x18dfae0)
at /home/vagrant/src/xdebug-2.4.0/xdebug_var.c:1285
0000007 0x00007f3c94f485a9 in add_single_value (str=0x7ffcc428b7e0,
zv=0x7f3c9b0182d0, html=0, collecton_level=1)
at /home/vagrant/src/xdebug-2.4.0/xdebug_stack.c:389
0000008 0x00007f3c94f48bd2 in xdebug_append_printable_stack (str=0x7ffcc428b7e0,
html=0) at /home/vagrant/src/xdebug-2.4.0/xdebug_stack.c:483
0000009 0x00007f3c94f28207 in xdebug_throw_exception_hook (
exception=0x7f3c9b018450) at /home/vagrant/src/xdebug-2.4.0/xdebug.c:1507
0000010 0x0000000000b0b38b in zend_throw_exception_internal (
exception=0x7f3c9b018450)
at /home/vagrant/src/php-src/Zend/zend_exceptions.c:163
0000011 0x0000000000b0fde7 in zend_throw_exception_object (
exception=0x7f3c9b018450)
at /home/vagrant/src/php-src/Zend/zend_exceptions.c:1074
0000012 0x0000000000b68d00 in ZEND_THROW_SPEC_VAR_HANDLER (
execute_data=0x7f3c9b0182e0)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:15176
0000013 0x0000000000b49358 in ZEND_USER_OPCODE_SPEC_HANDLER (
execute_data=0x7f3c9b0182e0)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:1568
0000014 0x0000000000b4490b in execute_ex (ex=0x7f3c9b0182e0)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:417
0000015 0x00007f3c94f29c81 in xdebug_execute_ex (execute_data=0x7f3c9b0182e0)
at /home/vagrant/src/xdebug-2.4.0/xdebug.c:1890
0000016 0x0000000000b45e3b in ZEND_DO_FCALL_SPEC_HANDLER (
execute_data=0x7f3c9b018170)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:800
0000017 0x0000000000b49358 in ZEND_USER_OPCODE_SPEC_HANDLER (
execute_data=0x7f3c9b018170)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:1568
0000018 0x0000000000b4490b in execute_ex (ex=0x7f3c9b018170)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:417
0000019 0x00007f3c94f29c81 in xdebug_execute_ex (execute_data=0x7f3c9b018170)
at /home/vagrant/src/xdebug-2.4.0/xdebug.c:1890
0000020 0x0000000000b4a05c in ZEND_CALL_TRAMPOLINE_SPEC_HANDLER (
execute_data=0x7f3c9b0180f0)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:1750
0000021 0x0000000000b49358 in ZEND_USER_OPCODE_SPEC_HANDLER (
execute_data=0x7f3c9b018170)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:1568
0000022 0x0000000000b4490b in execute_ex (ex=0x7f3c9b018170)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:417
0000023 0x00007f3c94f29c81 in xdebug_execute_ex (execute_data=0x7f3c9b018170)
at /home/vagrant/src/xdebug-2.4.0/xdebug.c:1890
0000024 0x0000000000ac37be in zend_call_function (fci=0x7ffcc428bfb0,
fci_cache=0x7ffcc428bf80)
at /home/vagrant/src/php-src/Zend/zend_execute_API.c:866
0000025 0x000000000089d5c3 in zif_call_user_func_array (
execute_data=0x7f3c9b0180f0, return_value=0x7f3c9b0180d0)
at /home/vagrant/src/php-src/ext/standard/basic_functions.c:4811
0000026 0x0000000000b42d99 in execute_internal (execute_data=0x7f3c9b0180f0,
return_value=0x7f3c9b0180d0)
at /home/vagrant/src/php-src/Zend/zend_execute.c:2042
0000027 0x00007f3c94f2a6a0 in xdebug_execute_internal (
current_execute_data=0x7f3c9b0180f0, return_value=0x7f3c9b0180d0)
at /home/vagrant/src/xdebug-2.4.0/xdebug.c:2037
0000028 0x0000000000b46078 in ZEND_DO_FCALL_SPEC_HANDLER (
execute_data=0x7f3c9b018030)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:844
0000029 0x0000000000b49358 in ZEND_USER_OPCODE_SPEC_HANDLER (
execute_data=0x7f3c9b018030)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:1568
0000030 0x0000000000b4490b in execute_ex (ex=0x7f3c9b018030)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:417
0000031 0x00007f3c94f29c81 in xdebug_execute_ex (execute_data=0x7f3c9b018030)
at /home/vagrant/src/xdebug-2.4.0/xdebug.c:1890
0000032 0x0000000000b4a05c in ZEND_CALL_TRAMPOLINE_SPEC_HANDLER (
execute_data=0x7f3c9b017f60)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:1750
0000033 0x0000000000b49358 in ZEND_USER_OPCODE_SPEC_HANDLER (
execute_data=0x7f3c9b018030)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:1568
0000034 0x0000000000b4490b in execute_ex (ex=0x7f3c9b018030)
at /home/vagrant/src/php-src/Zend/zend_vm_execute.h:417
#35 0x00007f3c94f29c81 in xdebug_execute_ex (execute_data=0x7f3c9b018030)

TagsNo tags attached.
Operating SystemCentOS 6.7
PHP Version7.0.5-7.0.9

Activities

derick

2016-12-04 16:04

administrator   ~0003912

I tried reproducing this, but when I put the three files from your https://github.com/phpspec/phpspec/issues/890#issuecomment-201492582 into one directory, and installing phpspec with "composer require phpspec/phpspec", and running it, I only get:

derick@whisky:/tmp/1312 $ php vendor/bin/phpspec run -v
0
0 specs
0 examples
0ms

stringerbell

2016-12-07 15:24

reporter   ~0003962

Sorry about that! I'll take a look and see if I can get more complete instructions.

stringerbell

2016-12-07 15:57

reporter   ~0003963

I created a repo here: https://github.com/stringerbell/xdebug-bug

If you clone it, and then run

composer install
phpspec run

You should be able to get the bug to show up.

Thanks very much!

derick

2016-12-08 21:25

administrator   ~0003964

Hi,

I tried this with your reproduce case - instead of "phpspec run" I had to use "bin/phpspec run" to make it work.

However, it works fine here, without any crashes, or without any valgrind warnings. And that's with Xdebug 2.4.0 too (2.5.0 is latest). I can't test right now with PHP 7.0.7, but didn't think that using 7.0.12/.13 would make a difference. If you can test that, that'd be good though.

However, I am not quite sure what "Skipped installation of bin bin/phpspec for package phpspec/phpspec: name conflicts with an existing file" means:

derick@whisky:~ $ pe 7.0dev
[PHP: 7.0.13-dev ]

derick@whisky:~ $ php -v
PHP 7.0.13-dev (cli) (built: Oct 30 2016 14:53:59) ( NTS DEBUG )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
with Zend OPcache v7.0.13-dev, Copyright (c) 1999-2016, by Zend Technologies
[PHP: 7.0.13-dev ]

derick@whisky:~ $ git clone https://github.com/stringerbell/xdebug-bug
Cloning into 'xdebug-bug'...
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 12 (delta 0), reused 12 (delta 0), pack-reused 0
Unpacking objects: 100% (12/12), done.
Checking connectivity... done.

[PHP: 7.0.13-dev ]
derick@whisky:~ $ cd xdebug-bug/

[GIT: master][PHP: 7.0.13-dev ]
derick@whisky:~/xdebug-bug $ php ~/composer.phar install
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file

  • Installing phpdocumentor/reflection-common (1.0)
    Loading from cache

  • Installing phpdocumentor/type-resolver (0.2.1)
    Loading from cache

  • Installing symfony/yaml (v3.2.0)
    Loading from cache

  • Installing symfony/process (v3.2.0)
    Loading from cache

  • Installing symfony/finder (v3.2.0)
    Loading from cache

  • Installing symfony/event-dispatcher (v3.2.0)
    Loading from cache

  • Installing symfony/polyfill-mbstring (v1.3.0)
    Loading from cache

  • Installing psr/log (1.0.2)
    Loading from cache

  • Installing symfony/debug (v3.2.0)
    Loading from cache

  • Installing symfony/console (v3.2.0)
    Loading from cache

  • Installing sebastian/recursion-context (2.0.0)
    Loading from cache

  • Installing sebastian/exporter (2.0.0)
    Loading from cache

  • Installing sebastian/diff (1.4.1)
    Loading from cache

  • Installing sebastian/comparator (1.2.2)
    Loading from cache

  • Installing webmozart/assert (1.2.0)
    Loading from cache

  • Installing phpdocumentor/reflection-docblock (3.1.1)
    Loading from cache

  • Installing doctrine/instantiator (1.0.5)
    Loading from cache

  • Installing phpspec/prophecy (v1.6.2)
    Loading from cache

  • Installing phpspec/php-diff (v1.1.0)
    Loading from cache

  • Installing phpspec/phpspec (3.2.2)
    Loading from cache

    Skipped installation of bin bin/phpspec for package phpspec/phpspec: name conflicts with an existing file
    symfony/event-dispatcher suggests installing symfony/dependency-injection ()
    symfony/event-dispatcher suggests installing symfony/http-kernel ()
    symfony/console suggests installing symfony/filesystem ()
    phpspec/phpspec suggests installing phpspec/nyan-formatters (Adds Nyan formatters)
    Generating autoload files

[GIT: master][PHP: 7.0.13-dev ]
derick@whisky:~/xdebug-bug $ bin/phpspec run
Foo
20 - it will segfault
exception [exc:Exception("")] has been thrown.

            50%                                50%                 2

1 specs
2 examples (1 passed, 1 broken)
95ms

[GIT: master][PHP: 7.0.13-dev ]
derick@whisky:~/xdebug-bug $ export USE_ZEND_ALLOC=0

[GIT: master][PHP: 7.0.13-dev USE_ZEND_ALLOC=0]
derick@whisky:~/xdebug-bug $ valgrind php -dxdebug.collect_params=1 -dxdebug.var_display_max_depth=10 bin/phpspec run
==18780== Memcheck, a memory error detector
==18780== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==18780== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info
==18780== Command: php bin/phpspec run
==18780==
Foo
20 - it will segfault
exception [exc:Exception("")] has been thrown.

            50%                                50%                 2

1 specs
2 examples (1 passed, 1 broken)
2870ms

==18780==
==18780== HEAP SUMMARY:
==18780== in use at exit: 8,365 bytes in 80 blocks
==18780== total heap usage: 244,462 allocs, 244,382 frees, 89,803,923 bytes allocated
==18780==
==18780== LEAK SUMMARY:
==18780== definitely lost: 1,864 bytes in 12 blocks
==18780== indirectly lost: 296 bytes in 2 blocks
==18780== possibly lost: 0 bytes in 0 blocks
==18780== still reachable: 6,205 bytes in 66 blocks
==18780== suppressed: 0 bytes in 0 blocks
==18780== Rerun with --leak-check=full to see details of leaked memory
==18780==
==18780== For counts of detected and suppressed errors, rerun with: -v
==18780== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

So I'm not sure what to do now...

stringerbell

2016-12-14 16:01

reporter   ~0004069

Sorry for the delay.

Hmm, not sure what's different. Out of curiosity, I updated my php version to the latest yum package, to 7.0.14. Hopefully that makes it easier to reproduce.

Here's my terminal:

[vagrant@i3ballot ~]$ php -v
PHP 7.0.14 (cli) (built: Dec 10 2016 11:58:43) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

[vagrant@i3ballot ~]$ git clone https://github.com/stringerbell/xdebug-bug
Initialized empty Git repository in /home/vagrant/xdebug-bug/.git/
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 12 (delta 0), reused 12 (delta 0), pack-reused 0
Unpacking objects: 100% (12/12), done.

[vagrant@i3ballot ~]$ cd xdebug-bug/
[vagrant@i3ballot xdebug-bug]$ composer install
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file

  • Installing phpdocumentor/reflection-common (1.0)
    Loading from cache

  • Installing phpdocumentor/type-resolver (0.2.1)
    Loading from cache

  • Installing symfony/yaml (v3.2.0)
    Loading from cache

  • Installing symfony/process (v3.2.0)
    Loading from cache

  • Installing symfony/finder (v3.2.0)
    Loading from cache

  • Installing symfony/event-dispatcher (v3.2.0)
    Loading from cache

  • Installing symfony/polyfill-mbstring (v1.3.0)
    Loading from cache

  • Installing psr/log (1.0.2)
    Loading from cache

  • Installing symfony/debug (v3.2.0)
    Loading from cache

  • Installing symfony/console (v3.2.0)
    Loading from cache

  • Installing sebastian/recursion-context (2.0.0)
    Loading from cache

  • Installing sebastian/exporter (2.0.0)
    Loading from cache

  • Installing sebastian/diff (1.4.1)
    Loading from cache

  • Installing sebastian/comparator (1.2.2)
    Loading from cache

  • Installing webmozart/assert (1.2.0)
    Loading from cache

  • Installing phpdocumentor/reflection-docblock (3.1.1)
    Loading from cache

  • Installing doctrine/instantiator (1.0.5)
    Loading from cache

  • Installing phpspec/prophecy (v1.6.2)
    Loading from cache

  • Installing phpspec/php-diff (v1.1.0)
    Loading from cache

  • Installing phpspec/phpspec (3.2.2)
    Loading from cache

    Skipped installation of bin bin/phpspec for package phpspec/phpspec: name conflicts with an existing file
    symfony/event-dispatcher suggests installing symfony/dependency-injection ()
    symfony/event-dispatcher suggests installing symfony/http-kernel ()
    symfony/console suggests installing symfony/filesystem ()
    phpspec/phpspec suggests installing phpspec/nyan-formatters (Adds Nyan formatters)
    Generating autoload files

[vagrant@i3ballot xdebug-bug]$ bin/phpspec run
1Segmentation fault

I'm unable to reproduce it if my /etc/php.d/xdebug.ini file doesn't have xdebug.collect_params = 1. (I get the same results as above when that setting isn't present)

Is there anything I can do to make your job easier, or info I can give you that would help?

derick

2016-12-14 16:15

administrator   ~0004070

I ran it with a debug build. I can try that.

derick

2016-12-14 16:22

administrator   ~0004071

I can reproduce this now, with a no-debug build and Xdebug 2.4.0 and 2.5.0.

stringerbell

2016-12-14 16:24

reporter   ~0004072

fantastic! Let me know if you need anything from me. Thank you.

derick

2016-12-17 15:35

administrator   ~0004078

I think I've fixed this in Git (the master and xdebug_2_5 branches)

Issue History

Date Modified Username Field Change
2016-06-13 20:53 stringerbell New Issue
2016-07-31 12:36 derick Category Usage problems => Usage problems (Crashes)
2016-07-31 12:38 derick Category Usage problems (Crashes) => Usage problems (Wrong Results)
2016-12-04 16:04 derick Note Added: 0003912
2016-12-04 16:04 derick Assigned To => derick
2016-12-04 16:04 derick Status new => feedback
2016-12-07 15:24 stringerbell Note Added: 0003962
2016-12-07 15:24 stringerbell Status feedback => assigned
2016-12-07 15:57 stringerbell Note Added: 0003963
2016-12-08 21:25 derick Note Added: 0003964
2016-12-08 21:25 derick Status assigned => feedback
2016-12-14 16:01 stringerbell Note Added: 0004069
2016-12-14 16:01 stringerbell Status feedback => assigned
2016-12-14 16:15 derick Note Added: 0004070
2016-12-14 16:22 derick Note Added: 0004071
2016-12-14 16:24 stringerbell Note Added: 0004072
2016-12-15 12:03 derick Target Version => 2.5.1
2016-12-17 15:35 derick Note Added: 0004078
2016-12-17 15:35 derick Status assigned => closed
2016-12-17 15:35 derick Resolution open => fixed
2016-12-17 15:35 derick Fixed in Version => 2.5.1
2020-03-12 16:35 derick Category Usage problems (Wrong Results) => Variable Display
2020-03-12 16:38 derick Category Variable Display => Uncategorized