Bug #70828 [Com]: php-fpm 5.6 with opcache crashes when referencing a non-existent constant

From: Date: Sun, 01 Nov 2015 15:07:12 +0000
Subject: Bug #70828 [Com]: php-fpm 5.6 with opcache crashes when referencing a non-existent constant
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196959@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70828&edit=1 ID: 70828 Comment by: cf0hay at gmail dot com Reported by: cf0hay at gmail dot com Summary: php-fpm 5.6 with opcache crashes when referencing a non-existent constant Status: Open Type: Bug Package: opcache Operating System: 64bit linux PHP Version: 5.6.15 Block user comment: N Private report: N New Comment: (gdb) bt #0 0x00000000007940d3 in ?? () #1 0x0000000000794205 in zend_hash_func () #2 0x00007f8d41921adc in ?? () from /usr/lib64/php5.6/lib64/opcache.so #3 0x00007f8d41928f53 in ?? () from /usr/lib64/php5.6/lib64/opcache.so #4 0x00007f8d4192911a in ?? () from /usr/lib64/php5.6/lib64/opcache.so #5 0x00007f8d41929364 in zend_accel_script_optimize () from /usr/lib64/php5.6/lib64/opcache.so #6 0x00007f8d41901fab in ?? () from /usr/lib64/php5.6/lib64/opcache.so #7 0x00007f8d41902d4c in ?? () from /usr/lib64/php5.6/lib64/opcache.so #8 0x00007f8d419035a7 in persistent_compile_file () from /usr/lib64/php5.6/lib64/opcache.so #9 0x0000000000783bab in zend_execute_scripts () #10 0x00000000006e999d in php_execute_script () #11 0x000000000084586e in main () Previous Comments: ------------------------------------------------------------------------ [2015-11-01 13:44:46] cf0hay at gmail dot com Description: ------------ A crash occurs when *all* of the following conditions met: * there is a "use const" statement in a namespace * a (static) function references that constant * that constant haven't been defined * the referencing function is called * opcache is enabled * FPM is the environmet * php 5.6 is the version - if there is no "use const", the old behavior works, as in it will use the constant from global namespace - if nothing referneces the constant, it will not crash - if the constant is defined before use, crash will not occur - if the referncing function is not called, crash will not occur - if opcache is *disabled*, crash not occurs (the code issues notices) - if run from CLI, crash not occurs (the code issues notices) - afaik php < 5.6 doesn't have this feature, and php 7.0 RC 6 is not affected, as it creates a fatal error instead, so only php 5.6 is affected Test script: --------------- <?php namespace test { use const nonexistent; class test { static function run(){ var_dump(nonexistent); } } } namespace { test\test::run(); } Expected result: ---------------- PHP Notice: Use of undefined constant nonexistent - assumed 'nonexistent' Actual result: -------------- Segmentation fault ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70828&edit=1

« previous php.bugs (#196959) next »