php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37976 Recursive object creation causes segfault
Submitted: 2006-06-30 18:54 UTC Modified: 2006-06-30 22:08 UTC
From: e at osterman dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.1.4 OS: Redhat
Private report: No CVE-ID: None
 [2006-06-30 18:54 UTC] e at osterman dot com
Description:
------------
Sorry if this is a duplicate bug; the words __construct and segfault appear thousands of times in this bug database.

If you try to construct an object of yourself in the constructor, the infinite recursion causes a segfault. Ofcourse, you never want to construct yourself like this, but then again, you never want to segfault either. 

Reproduce code:
---------------
<?
/*
 * Tested on: 
 * PHP 5.1.4 (cli) (built: May 18 2006 09:50:08)
 * Copyright (c) 1997-2006 The PHP Group
 * Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend  Technologies
 */

class SegFault
{
    public function __construct()
    {
        new SegFault();
    }

}

$breakme = new SegFault();

?>


Expected result:
----------------
PHP Warning: something to the effect of infinite recursion

Actual result:
--------------
Segmentation fault

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-30 21:50 UTC] judas dot iscariote at gmail dot com
this is the expected behaviuor, if you want recursion control to aid development or something, install xdebug.
 [2006-06-30 22:08 UTC] tony2001@php.net
Yes, endless recursion is likely to eat all the RAM and/or cause a crash. 
That was already reported thousands of times.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 06:01:29 2024 UTC