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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 20:01:30 2024 UTC