|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77867 PHP silently kills itself when referencing an invalid array key in a constant
Submitted: 2019-04-09 07:45 UTC Modified: 2019-04-28 04:22 UTC
From: mcpe4life62 at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: *General Issues
PHP Version: 7.2.17 OS: Windows 10
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-04-09 07:45 UTC] mcpe4life62 at gmail dot com
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 = [
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 = [
(new BrokenClass());

Expected result:
A Compile Error should be thrown.

Actual result:
PHP Silently shuts down without any warning or error message.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-04-09 07:55 UTC]
I can't reproduce this on Linux:

I also checked that it works with opcache loaded and that no valgrind warnings are triggered.
 [2019-04-09 08:31 UTC]
-Package: Compile Failure +Package: *General Issues
 [2019-04-18 07:25 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2019-04-18 07:25 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read for *NIX and for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
 [2019-04-28 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 01 18:01:28 2024 UTC