View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0001625 | Xdebug | Step Debugging | public | 2019-02-04 11:10 | 2019-02-16 00:38 |
| Reporter | dv-ds | Assigned To | |||
| Priority | high | Severity | crash | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Platform | x86_64 | OS | macOS | OS Version | 10.14.2 |
| Product Version | 2.7.0rc1 | ||||
| Target Version | 2.7.0 | Fixed in Version | 2.7.0RC2 | ||
| Summary | 0001625: Work around ABI conflicts in PHP 7.3.0/PHP 7.3.1 | ||||
| Description | Some evaluations are possible, others are not. In the cases where it doesn't work, the end result is something like this: [Mon Feb 04 11:49:24.093890 2019] [core:notice] [pid 10169] AH00052: child pid 39934 exit signal Segmentation fault (11) For what it's worth, I'm fairly certain this occurred also in 2.7.0beta1, but I did not investigate that further as the major issue for me at that point was the opcache issue. | ||||
| Steps To Reproduce | Setup index.php as follows and navigate to /?foo=bar <?php $a = 1; | ||||
| Additional Information | Setup:
| ||||
| Tags | No tags attached. | ||||
| Operating System | macOS | ||||
| PHP Version | 7.3.2-7.3.4 | ||||
|
|
I just noticed I set "PHP Version" incorrectly, and don't see any way to modify it. It's 7.3.1 as indicated in the other section. |
|
|
I think this is a duplicate of 0001626 — can you please see if you can make a GDB trace as is explained at https://xdebug.org/support.php#crash ? |
|
|
I can't get GDB to work even with a simple hello world program unfortunately. It's been like that for a long time and I gave up trying to fix it. It's a homebrew installation, and I'd rather not touch it as Homebrew very often breaks things for me when I upgrade things, due to messed up dependencies and whatnot. However, I am able to attach with LLDB (sudo lldb -p nnnn). Here's what I got, and see also attached xdebug log from an earlier session, explained below, do you need more? Program used: <?php error_log("PID: " . getmypid()); sleep(20); $a = 1; // LLDB log below indicates crash when hovering over $a, at breakpoint (lldb) continue
For the xdebug log: (/?foo=bar) Evaluating $a in console works fine: Hovering over $a - crash: Evaluating $_GET in console - crash: (and reconnect fails because the thread already died, I get similar results when running this on a running thread) |
|
|
This is really useful. If only I could reproduce this at home (or have access to your debugging session)... It's possible to compile Xdebug with debugging symbols, by using: ./configure --with-xdebug-dev instead of the normal ./configure I'm curious to see what the values of the local vars and arguments are. For both this frame (top) one, and lower ones. Can you show the output of the following commands on lldb: frame 0 frame 1 frame 2 |
|
|
Hm, if I try ./configure --enable-xdebug-dev (I assume that's the one you meant, I get an error if I try --with-xdebug-dev), some warnings are treated as fatal, which they are not otherwise. Example: xdebug/xdebug.c:1822:107: error: format specifies type 'long' but the argument has type 'zend_long' (aka 'long long') [-Werror,-Wformat] |
|
|
Found a quicker path and applied this diff to mute the warnings, will get back to you shortly: $ git diff
|
|
|
I was able to compile, but things are not working out yet:
How can I completely disable optimization? The frame info I can get at this point is thus quite uninformative, so I'll refrain from posting the rest unless you think it might still be of use: (lldb) frame select 0 (zend_ulong) index_key = <variable not available> (zend_string ) hash_key = 0x0000000111e61060 (xdebug_str *) parent_name = <variable not available> (xdebug_var_export_options *) options = <variable not available> (xdebug_xml_node ) node = 0x00007fa61271cd90 (xdebug_str) full_name = <variable not available> (zend_string ) i_string = 0x0000000111e61900 |
|
|
It was phpize that introduced -O2. Hacked it away manually before ./configure --enable-xdebug-dev && make and was able to get some debug info, see attached lldb-output.txt. Some notes:
|
|
|
Thanks for that. I just did a live debugging session with somebody through IRC and screensharing, and we came to the same conclusions, with albeit slightly better output (See attached screenshots). Unfortunately, I still don't understand what goes wrong, except for the crash... |
|
|
Looks like I got the same results as both dv-ds and derick from my ticket 0001626. I tried to check the value of i_string from within lldb without much success. |
|
|
Is the following of any use? (lldb) frame select 0 (lldb) p/x |
|
|
Note that the address mentioned above evaluates as follows: (lldb) dis -a |
|
|
This almost looks like the php_addslashes function call is wrong. But Xdebug does nothing special with this function. I am wondering whether there is another memory corruption going on here. Maybe it's worth trying to do this with the zend memory manager turned off, which you can do by setting "export USE_ZEND_ALLOC=0" as an environment variable (but make sure they propagate to PHP/PHP-FPM — phpinfo() and or var_dump($_ENV) should tell you). |
|
|
I set USE_ZEND_ALLOC=0 now and phpinfo() confirms it ($_ENV does not however). However, I still get the same error and the same instructions:
-> 0x107fe5ef3 <+643>: callq *%rcx |
|
|
I have been talking to Nikita today, and it seems that a hunch "it looks like addslashes is not a function" seems to be correct. Nikita theorizes that this problem occurs because PHP and Xdebug are targetted at a different architecture. PHP's php_addslashes calls have an optimisation for SSE4.2 systems, which gets only enabled on machines that support it. So if PHP was compiled on a system that doesn't enable it, and yours does, then the calling convention is off and you get a crash. It's possible that a hint on what happens can be found in the ./configure line that can be found in phpinfo() output (<code>php -i | grep Configure</code>). Unfortunately, there is currently no clean way around this without a hack (i.e., copying the php_addslashes function into the Xdebug source code). Nikita suggests to try to compile Xdebug with <code> ./configure CFLAGS="-march=native" </code> to see if that addresses the problem until this can be sorted out in PHP itself. |
|
|
Looks like you beat me to it. I just found these lines in the PHP src which are exactly what you describe. https://github.com/php/php-src/blob/php-7.3.1/ext/standard/php_string.h#L127-L133 |
|
|
Please excuse any misunderstanding about this complex code, this might be way of the mark. Would it be possible to leverage the code in the PHP source that checks for the SSE4.2 instructions in XDebug 2.7 as well? https://github.com/php/php-src/blob/php-7.3.1/ext/standard/string.c#L3902-L3919 |
|
|
That seems to be the case indeed! I don't see any mention of SSE4.2 in the output of php -i, whereas sysctl -a | grep machdep.cpu.features lists it. You did not hear it from me, but what I did now was:
There are a bunch of flags in there, so I have no idea if there is more that needs to be hacked. Probably some upstream flag is a less bad thing to mess with. And clearly this is not a proper solution... Nevertheless, after this change I can't reproduce the scenarios I described in "Steps To Reproduce". I have not done extensive testing, but it looks very promising. Assuming no other issues pop up, this is good enough on my side for now as I also can't think of a non-awkward workaround on the Xdebug side. It doesn't necessarily merit closing the issue, but I'll leave that up to you and others affected by this issue. |
|
|
This has now been fixed in PHP (for PHP 7.3.3 (https://github.com/php/php-src/pull/3826/files) and PHP 7.4-dev (https://github.com/php/php-src/pull/3828/files)). I will be adding a workaround for Xdebug for the two broken PHP versions (i.e., copy the addslashes code into the Xdebug source code, so that no ABI conflicts exist), and then release a new release candidate. |
|
|
Fixed in GIT for Xdebug 2.7.0RC2 (soon to be released) |
|
|
Verified that Xdebug 2.7.0RC2 fixes the issues I was having from ticket 0001627. |