php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63107 call_user_func[_array] with property holding Closure causes crash
Submitted: 2012-09-18 07:30 UTC Modified: 2012-09-18 07:53 UTC
From: sanity at wh00s dot net Assigned: laruence (profile)
Status: Closed Package: Reproducible crash
PHP Version: 5.3.17 OS: Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sanity at wh00s dot net
New email:
PHP Version: OS:

 

 [2012-09-18 07:30 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-18 07:44 UTC] 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:44 UTC] laruence@php.net
-Status: Open +Status: Not a bug
 [2012-09-18 07:51 UTC] laruence@php.net
-Status: Not a bug +Status: Re-Opened
 [2012-09-18 07:51 UTC] 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:53 UTC] laruence@php.net
.... re-opened unintentionally
 [2012-09-18 07:53 UTC] laruence@php.net
-Status: Re-Opened +Status: Closed -Assigned To: +Assigned To: laruence
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 20:01:33 2025 UTC