Bug #72469 [Opn->Nab]: Coredump while constructing the class in the constructor
Edit report at https://bugs.php.net/bug.php?id=72469&edit=1
ID: 72469
Updated by: pajoye@php.net
Reported by: brupje at gmail dot com
Summary: Coredump while constructing the class in the
constructor
-Status: Open
+Status: Not a bug
Type: Bug
Package: Reproducible crash
Operating System: Ubuntu 14.04.4 LTS
PHP Version: 7.0.7
Block user comment: N
Private report: N
New Comment:
This code is the same than:
function foo(){foo();}
Endless recursion leading to stack exhaustion and crash.
Previous Comments:
------------------------------------------------------------------------
[2016-06-22 11:56:56] brupje at gmail dot com
Description:
------------
I am using the ondrej-php compiled 7.0.7 packages on a up-to-date Ubuntu 14.04 LTS. I was doing some
bad coding practises as per our current cms when a coredump occurred. I was able to create a test
script that will reproducibly on my system will coredump apache.
The original code was much longer and more complex with subclasses, but I was able to minimize it to
the code below. Basically what I did was put the class into a global variable and the use that
global variable to call a non-existing function. It coredumps at creating the class in constructor.
Constructing the class you are currently constructing into a global is a one thing that should not
be allowed I think, which would fix this particular issue at least.
Test script:
---------------
<?php
class foo {
public function __construct() {
$_GLOBAL['bar'] = new foo();
}
}
$foo = new foo();
?>
Expected result:
----------------
Error that you can't create the partial class in the constructor.
Actual result:
--------------
Coredump in apache child
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72469&edit=1
Thread (2 messages)