|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50261 Crash When Calling Parent Constructor with call_user_func()
Submitted: 2009-11-22 10:05 UTC Modified: 2010-02-08 16:52 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: tom at tomwardrop dot com Assigned: dmitry (profile)
Status: Closed Package: Reproducible crash
PHP Version: 5.3, 6 OS: *
Private report: No CVE-ID: None
 [2009-11-22 10:05 UTC] tom at tomwardrop dot com
If class B, extends Class A, and class B calls Class A's constructor in its own contructor by using call_user_func("parent", "__construct"), and if class A's constructor is defined as the class name rather than "__construct", then PHP seems to crash (which results in Apache 2 crashing). Problem still exists with all extensions disabled.

Reproduce code:

class testClass
	function testClass ()
		echo 'Output string!';

class testClass2 extends testClass
	function __construct ()
		call_user_func(array('parent', '__construct'));

new testClass2;


Expected result:
The above code should echo out the string 'Output string!'. This code works correctly when "call_user_func" or "call_user_func_array" are not used.

Actual result:
call_user_func() and call_user_func_array(), cause PHP and as a result, Apache 2 to crash. When running PHP DBG debugger, the crash happens on the execution of call_user_func() line. The Windows event log notes that httpd.exe (apache) had crashed, blaming php5ts.dll for the fault.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-22 10:08 UTC] tom at tomwardrop dot com
To clarify, replacing...

call_user_func(array('parent', '__construct'));


parent::__construct(); as expected, hence it's definitely a problem with the "call_user_func" and "call_user_func_array" functions.
 [2009-11-22 18:37 UTC]
In PHP_5_2 you get this error and no crash:
Warning: call_user_func(parent::__construct): First argument is expected to be a valid callback..

 [2009-11-23 23:07 UTC]
Automatic comment from SVN on behalf of felipe
Log: - Added test for bug #50261
 [2009-11-24 09:22 UTC]
Dmitry, could you take a look at it?
 [2009-11-30 11:39 UTC]
Automatic comment from SVN on behalf of dmitry
Log: Fixed bug #50261 (Crash When Calling Parent Constructor with call_user_func())
 [2009-11-30 11:40 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

 [2009-11-30 12:52 UTC] tom at tomwardrop dot com
Awesome turn around time. Well done guys, and thanks.
 [2010-02-08 16:52 UTC]
The patch for this bug had an accidental change which was reverted in next revision:
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Mar 02 16:01:32 2024 UTC