-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In some specific cases SWITCH with one default statement will cause segfault #11245
In some specific cases SWITCH with one default statement will cause segfault #11245
Comments
It's an optimizer issue.
|
Thanks for the comment. Any workaround for now, or to fix that - opcache needs to be disabled (or maybe I can update php to recent version)? |
@slawomir-pryczek PHP 8.2 suffers from the same issue. You can disable SSA based optimization with |
Its already broken before SSA is constructed:
Free's V3, but V3 is nowhere to be found. Dumping the opcodes before the optimisation pipeline runs shows that V3 used to be the call result of xx(). |
…ment will cause segfault) The block optimizer pass allows the use of sources of the preceding block if the block is a follower and not a target. This causes issues when trying to remove FREE instructions: if the source is not in the block of the FREE, then the FREE and source are still removed. Therefore the other successor blocks, which must consume or FREE the temporary, will still contain the FREE opline. This opline will now refer to a temporary that doesn't exist anymore, which most of the time results in a crash. For these kind of non-local scenarios, we'll let the SSA based optimizations handle those cases.
* PHP-8.1: Fix GH-11245 (In some specific cases SWITCH with one default statement will cause segfault)
* PHP-8.2: Fix GH-11245 (In some specific cases SWITCH with one default statement will cause segfault)
Description
The following code:
crash.php
Resulted in this output:
Hi Guys, i found something totally weird. Basically when you put this code on the server it'll cause php to segfault each time it is executed. The parameter of switch needs to be function call, you need one default branch and you need the if empty and you also need return. Now the weird part is that for the variables $a, $b, $c it DEPENDS on the URL it seems. When i put the file on /a/b/crash.php i need to keep $a, $b, $c... if i put it in the root dir of the website i need to keep only $a.
Segfaults each time after you get the correct number of variables prior to switch.
Also:
[xx@xxxxx]$ php -f ping_pp.php
Segmentation fault (core dumped)
[5356978.846558] traps: php[2973761] general protection fault ip:55c832a10f17 sp:7ffc3e0f4058 error:0 in php[55c832800000+2e7000]
Attaching core dump:
Stack trace of thread 2973761:
#0 0x000055c832a10f17 ZEND_FREE_SPEC_TMPVAR_HANDLER (php + 0x410f17)
#1 0x000055c832a5b1b9 execute_ex (php + 0x45b1b9)
#2 0x000055c832a64899 zend_execute (php + 0x464899)
#3 0x000055c8329f3c80 zend_execute_scripts (php + 0x3f3c80)
#4 0x000055c83298ea8a php_execute_script (php + 0x38ea8a)
#5 0x000055c832addfdd do_cli (php + 0x4ddfdd)
#6 0x000055c83283dcd3 main (php + 0x23dcd3)
#7 0x00007ff89bff2510 __libc_start_call_main (libc.so.6 + 0x27510)
#8 0x00007ff89bff25c9 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x275c9)
#9 0x000055c83283de25 _start (php + 0x23de25)
ELF object binary architecture: AMD x86-64
PHP Version
PHP Version 8.1.18
Operating System
6.1.9-200.fc37.x86_64 (Fedora Core 37)
The text was updated successfully, but these errors were encountered: