#50261 [Ver->Asn]: Crash When Calling Parent Constructor with call_user_func()
| From: | tony2001@php.net | Date: | Tue, 24 Nov 2009 09:22:13 +0000 |
| Subject: | #50261 [Ver->Asn]: Crash When Calling Parent Constructor with call_user_func() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-145005@lists.php.net to get a copy of this message | ||
ID: 50261
Updated by: tony2001@php.net
Reported By: tom at tomwardrop dot com
-Status: Verified
+Status: Assigned
Bug Type: Reproducible crash
Operating System: *
PHP Version: 5.3, 6
-Assigned To:
+Assigned To: dmitry
New Comment:
Dmitry, could you take a look at it?
Previous Comments:
------------------------------------------------------------------------
[2009-11-23 23:07:07] 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-22 18:37:37] 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-22 10:08:22] 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 10:05:54] 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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50261&edit=1