php.net |  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
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: tom at tomwardrop dot com Assigned: dmitry
Status: Closed Package: Reproducible crash
PHP Version: 5.3, 6 OS: *
Private report: No CVE-ID:
 [2009-11-22 10:05 UTC] tom at tomwardrop dot com
Description:
------------
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:
---------------
<?php

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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

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

...with...

parent::__construct();

...works 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] jani@php.net
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] svn@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=291248
Log: - Added test for bug #50261
 [2009-11-24 09:22 UTC] tony2001@php.net
Dmitry, could you take a look at it?
 [2009-11-30 11:39 UTC] svn@php.net
Automatic comment from SVN on behalf of dmitry
Revision: http://svn.php.net/viewvc/?view=revision&revision=291488
Log: Fixed bug #50261 (Crash When Calling Parent Constructor with call_user_func())
 [2009-11-30 11:40 UTC] dmitry@php.net
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
http://snaps.php.net/.
 
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] dmitry@php.net
The patch for this bug had an accidental change which was reverted in next revision: http://svn.php.net/viewvc/?view=revision&revision=291491
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 23 17:01:58 2014 UTC