php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72469 Coredump while constructing the class in the constructor
Submitted: 2016-06-22 11:56 UTC Modified: 2016-06-22 12:38 UTC
From: brupje at gmail dot com Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 7.0.7 OS: Ubuntu 14.04.4 LTS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: brupje at gmail dot com
New email:
PHP Version: OS:

 

 [2016-06-22 11:56 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-22 12:38 UTC] pajoye@php.net
-Status: Open +Status: Not a bug
 [2016-06-22 12:38 UTC] pajoye@php.net
This code is the same than:

function foo(){foo();}
Endless recursion leading to stack exhaustion and crash.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 15:01:34 2025 UTC