php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31475 calling of the parent class method leads to recursion and segmentation fault
Submitted: 2005-01-10 17:24 UTC Modified: 2005-01-10 17:35 UTC
From: public at grik dot net Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.0.3 OS: linux
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: public at grik dot net
New email:
PHP Version: OS:

 

 [2005-01-10 17:24 UTC] public at grik dot net
Description:
------------
When I moved my classes hierarchy code from the PHP 4 to the PHP 5 and renamed costructors from the class names to "__construct", I faced a segmentation fault.

The constructor calls the parent's constructor. 
Parent's constructor calls another method, overloaded in the child's class.
That overloaded method from the child's class calls the constructor that calls the parent's constructor again.
But instead of the endless loop I get the segfault.

Reproduce code:
---------------
class A{
    function a1(){
        echo ' class a ';
    }
    function a2(){
        $this->a1();
    }
}
class B extends A {
    function a1(){
        $this->a2();
    }
    function __construct(){
        parent::a2();
    }
}
$a= new B();

Expected result:
----------------
The endless loop until script execution time expires:
B::a1() calls A::a2() and vice versa

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-10 17:31 UTC] tony2001@php.net
Submitted twice.
 [2005-01-10 17:35 UTC] public at grik dot net
Sorry, this is a repost from the #31474,
caused by my problem of the internet connection.
Sorry.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 13:01:30 2024 UTC