Bug #63107 [ReO->Csd]: call_user_func[_array] with property holding Closure causes crash
| From: | laruence@php.net | Date: | Tue, 18 Sep 2012 07:53:04 +0000 |
| Subject: | Bug #63107 [ReO->Csd]: call_user_func[_array] with property holding Closure causes crash | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-173529@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63107&edit=1
ID: 63107
Updated by: laruence@php.net
Reported by: sanity at wh00s dot net
Summary: call_user_func[_array] with property holding Closure
causes crash
-Status: Re-Opened
+Status: Closed
Type: Bug
Package: Reproducible crash
Operating System: Windows 7
PHP Version: 5.3.17
-Assigned To:
+Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
.... re-opened unintentionally
Previous Comments:
------------------------------------------------------------------------
[2012-09-18 07:51:56] laruence@php.net
and about the $bar->prop();
PHP will think you are try to call a method named "prop", but not calling the
value stroed in $bar->prop.
anyway, you can archieve this by:
$a = $bar->prop;
$a();
------------------------------------------------------------------------
[2012-09-18 07:44:43] laruence@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
it's not a closure specific issue
it's a stack overflow segfault due to recursive function call.
------------------------------------------------------------------------
[2012-09-18 07:30:11] sanity at wh00s dot net
Description:
------------
Having an anonymous function as a class property and executing it with
call_user_func() or call_user_func_array() causes PHP to crash.
Test script:
---------------
class Foo {
function __call($name, $args) {
call_user_func(array($this, $name), $args);
}
}
$bar = new Foo;
$bar->prop = function(){};
$bar->prop();
/* circumventing it can be achieved with the following: */
$method = $this->{$name};
call_user_func($method, $args);
Expected result:
----------------
Successful exeuction of anonymous function (or at least an error message).
Actual result:
--------------
PHP crashes.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63107&edit=1