Bug #77867 [NEW]: PHP silently kills itself when referencing an invalid array key in a constant

From: Date: Tue, 09 Apr 2019 07:45:55 +0000
Subject: Bug #77867 [NEW]: PHP silently kills itself when referencing an invalid array key in a constant
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220375@lists.php.net to get a copy of this message
From: mcpe4life62 at gmail dot com Operating system: Windows 10 PHP version: 7.2.17 Package: Compile Failure Bug Type: Bug Bug description:PHP silently kills itself when referencing an invalid array key in a constant Description: ------------ Adding a class / interface constant that references to another constant via an array key that's non-existent kills the PHP process silently. (without invoking die() or exit()) There are no error messages thrown, nor a warning, or anything. PHP just dies. There are two different results on two different scenarios. If this bug was done on an interface, PHP silently kills itself, as mentioned for several times. If this bug was done on a class, PHP Freezes silently and refuses to do anything. I've only tested this for a few minutes, I don't know if it un-freezes and exits after a while. Due to no error messages are being displayed, this made debugging it a bit tricky at first. It took me quite a few minutes before finding out that it was an invalid array key access. Even while I'm using PHPStorm (the class constant 'ARRAY_1' is an empty array), the erroneous code does not get pointed out or highlighted. Test script: --------------- // Only use one of these to get different results. // Insta-kill interface BrokenInterface { // this can be anything... even null. just with a non-existent key public const ARRAY_1 = []; public const ARRAY_2 = [ self::ARRAY_1["nonExistentKey"] ]; } class UseThisClass implements BrokenInterface {} (new UseThisClass()); // Freeze class BrokenClass { // this can be anything... even null. just with a non-existent key public const ARRAY_1 = []; public const ARRAY_2 = [ self::ARRAY_1["nonExistentKey"] ]; } (new BrokenClass()); Expected result: ---------------- A Compile Error should be thrown. Actual result: -------------- PHP Silently shuts down without any warning or error message. -- Edit bug report at https://bugs.php.net/bug.php?id=77867&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77867&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77867&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77867&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77867&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77867&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77867&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77867&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77867&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77867&r=support Expected behavior: https://bugs.php.net/fix.php?id=77867&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77867&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77867&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77867&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77867&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77867&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77867&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77867&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77867&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77867&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77867&r=mysqlcfg

« previous php.bugs (#220375) next »