-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
Prevent segmentation fault in Reflection->getParameters() #504
Conversation
…ive php function has been disabled via disabled_functions.
A bit more history on this one, our staging environment started segmentation faulting only on cli scripts. Enabling the core dump files and running through
Running through
Gradually debugging through Stacktrace eventually showed we had passthru disabled and the cli framework was using a call to passthru to run |
Thank you for finding and fixing such a nasty bug! Can you please contribute a regression test too, so we will avoid having this bug pop up an other time in the future? |
@Jean85 The nature of a segmentation fault is a hard exit from PHP which would interesting to cover with a test. The other obstacles would be limiting the test to only PHP 5.6 as >= 7 seems to be ok and being able to configure php.ini disable_functions for that test. running a quick idea on the test script above: var_dump(ini_get('disable_functions'));
ini_set('disable_functions', 'passthru');
var_dump(ini_get('disable_functions')); results in
disable_functions can't be set inside the php process ... |
I don't think this is testable, a segfault is not very testable with PHPUnit. So I don't think we can test for this. |
This should be fixed in the branch of the 2.0 version too. @Caffe1neAdd1ct Would you mind to open a new PR to address it? |
Why shouldn't this be fixes in 1.x @ste93cry? |
I think you misunderstood what I've said. It should be fixed in both branches, not only in 1.x |
@ste93cry definitely did 👍 Sorry about that! And ofcourse @Caffe1neAdd1ct, thanks for finding, reporting and fixing! |
@stayallive why it shouldn't be testable? A segfault is a test failure all the same. Calling the piece of code with a disabled function is enough to trigger the bug. So something like: $this->assertNotEmpty(ini_get('disable_functions'));
$disabledFunction = ini_get('disable_functions')[0];
// make call to $disabledFunction to trigger code ...should be enough. The fact that PHP 7+ is fine on itself is good because it will mean that the test can remain, the fix will be removed once PHP 7+ will be required. |
My concern would be the testing process crashing due to the segfault, not try{} catchable, would need to run in a separate process and determine the result possibly? Sure i'll try and have a look at raising a PR to 2.* shortly. |
Since you already committed the fix, making the tests fatal shouldn't be an issue. It would fatal only if someone removes your fix, so that test should warn him and teach him a good lesson 😄 |
When a native php function has been disabled via disabled_functions (php.ini) calling getParameters() on the reflection object of the disabled function causes a segmentation fault on PHP 5.6.31.
Reproducible on both Arch Linux and CentOS 6 with the following script:
php.ini
console.php
Run straight through either php or php-cli
php56 console.php
gives a segmentation fault as follows:Testing through php 7 does not segfault and reflection seems to be able to cope with the disabled function: