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

From: Date: Sun, 01 Nov 2015 13:44:48 +0000
Subject: Bug #70828 [NEW]: php-fpm 5.6 with opcache crashes when referencing a non-existent constant
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196958@lists.php.net to get a copy of this message
From:             cf0hay at gmail dot com
Operating system: 64bit linux
PHP version:      5.6.15
Package:          opcache
Bug Type:         Bug
Bug description:php-fpm 5.6 with opcache crashes when referencing a non-existent constant

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 bug report at https://bugs.php.net/bug.php?id=70828&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=70828&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=70828&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=70828&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=70828&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=70828&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=70828&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=70828&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=70828&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=70828&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=70828&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=70828&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=70828&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=70828&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70828&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=70828&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=70828&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=70828&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70828&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=70828&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=70828&r=mysqlcfg



Thread (6 messages)

« previous php.bugs (#196958) next »