Edit report at http://bugs.php.net/bug.php?id=52928&edit=1
ID: 52928 Updated by: johan...@php.net Reported by: M8R-nheyum at mailinator dot com Summary: Segfault using parent::_construct -Status: Open +Status: Bogus Type: Bug Package: Scripting Engine problem Operating System: CentOS release 4.8 PHP Version: 5.3.3 Block user comment: N Private report: N New Comment: This is an endless recursion Endless recursion gives a stack overflow which causes a segfault. call_user_func_array(array($this, 'parent::__construct'), $args); Takes $this's scope so get_class($this) and then the parent's constructor. Previous Comments: ------------------------------------------------------------------------ [2010-11-30 12:17:59] weishj at qq dot com If the parent class is not defined, it also end up with segmentation fault. <?php class base { function __construct(){ call_user_func(array($this,'parent::__construct')); } } class demo extends base{ function __construct(){ parent::__construct(); } } $z = new demo; ?> ------------------------------------------------------------------------ [2010-09-27 04:24:04] cataphr...@php.net Stack overflow on Windows, trunk. ------------------------------------------------------------------------ [2010-09-27 02:26:56] fel...@php.net This is causing an infinite recursion, but works fine on 5.2.15-dev. ------------------------------------------------------------------------ [2010-09-27 01:14:54] M8R-nheyum at mailinator dot com Description: ------------ When calling parent::__construct using call_user_func_array, a segfault occurs. Script to reproduce attached below. This worked in 5.2.14. Expected: instantiation of class Actual: segfault Notes: Only occurs with multiple nesting levels. A single level doesn't cause this. Test script: --------------- <? class baseA{ function foo(){ return 'bar'; } function __construct(){ foo(); } } class baseB extends baseA { function __construct(){ $args = func_get_args(); call_user_func_array(array($this, 'parent::__construct'), $args); } } class demo extends baseB{ function __construct(){ $args = func_get_args(); call_user_func_array(array($this, 'parent::__construct'), $args); } } $z = new demo('d'); ?> Expected result: ---------------- instantiation of class Actual result: -------------- segfault. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52928&edit=1