php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70630 Closure::call/bind() crash with ReflectionFunction->getClosure()
Submitted: 2015-10-03 22:55 UTC Modified: 2015-10-03 22:56 UTC
From: [email protected] Assigned: bwoebi (profile)
Status: Closed Package: Reproducible crash
PHP Version: master-Git-2015-10-03 (Git) OS: *
Private report: No CVE-ID: None
 [2015-10-03 22:55 UTC] [email protected]
Description:
------------
Closure::call() and Closure::bind() on functions (userland or internal) crash, when the functions are raw functions without class/scope context.

Test script:
---------------
class a {}
$x = (new ReflectionFunction("substr"))->getClosure();

$x->call(new a);
// or
Closure::bind($x, new a, "a");

Expected result:
----------------
Warning: Cannot bind closure of a function to an object

Actual result:
--------------
Segmentation Fault

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-10-03 22:56 UTC] [email protected]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: bwoebi
 [2015-10-03 23:43 UTC] [email protected]
Automatic comment on behalf of [email protected]
Revision: http://git.php.net/?p=php-src.git;a=commit;h=517b5536259ecf7697f353f4bfbafde857fc1f81
Log: Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure()) This additionally removes support for binding to an unknown (not in parent hierarchy) scope. Removing support for cross-scope is necessary for certain compile-time assumptions (like class constants) to prevent unexpected results
 [2015-10-03 23:43 UTC] [email protected]
-Status: Assigned +Status: Closed
 [2015-10-03 23:44 UTC] [email protected]
Automatic comment on behalf of [email protected]
Revision: http://git.php.net/?p=php-src.git;a=commit;h=517b5536259ecf7697f353f4bfbafde857fc1f81
Log: Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure()) This additionally removes support for binding to an unknown (not in parent hierarchy) scope. Removing support for cross-scope is necessary for certain compile-time assumptions (like class constants) to prevent unexpected results
 [2015-10-06 22:51 UTC] [email protected]
Automatic comment on behalf of [email protected]
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e0b3b3c7524603d57dce62ae1cb1eae3b1bc3e42
Log: Revert "Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure())"
 [2015-10-09 08:49 UTC] [email protected]
Automatic comment on behalf of [email protected]
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0847681b1ab40193815285a4e9736a058372bb8c
Log: Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure())
 [2015-10-13 10:12 UTC] [email protected]
Automatic comment on behalf of [email protected]
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0847681b1ab40193815285a4e9736a058372bb8c
Log: Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure())
 [2015-10-13 10:12 UTC] [email protected]
Automatic comment on behalf of [email protected]
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e0b3b3c7524603d57dce62ae1cb1eae3b1bc3e42
Log: Revert "Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure())"
 [2015-10-13 10:12 UTC] [email protected]
Automatic comment on behalf of [email protected]
Revision: http://git.php.net/?p=php-src.git;a=commit;h=517b5536259ecf7697f353f4bfbafde857fc1f81
Log: Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure()) This additionally removes support for binding to an unknown (not in parent hierarchy) scope. Removing support for cross-scope is necessary for certain compile-time assumptions (like class constants) to prevent unexpected results
 [2015-10-19 08:43 UTC] lisachenko dot it at gmail dot com
Hello, I think that described behaviour should be correct only for raw functions, applied to the objects. Currently, patch also disables rebinding of closures from methods between objects, which is not correct, see https://3v4l.org/cZtbI#v700rc5

I wrote about this case in internals too, please join discussion as it's introduces a BC break.
 [2016-07-20 11:36 UTC] [email protected]
Automatic comment on behalf of [email protected]
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0847681b1ab40193815285a4e9736a058372bb8c
Log: Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure())
 [2016-07-20 11:36 UTC] [email protected]
Automatic comment on behalf of [email protected]
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e0b3b3c7524603d57dce62ae1cb1eae3b1bc3e42
Log: Revert "Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure())"
 [2016-07-20 11:36 UTC] [email protected]
Automatic comment on behalf of [email protected]
Revision: http://git.php.net/?p=php-src.git;a=commit;h=517b5536259ecf7697f353f4bfbafde857fc1f81
Log: Fixed bug #70630 (Closure::call/bind() crash with ReflectionFunction->getClosure()) This additionally removes support for binding to an unknown (not in parent hierarchy) scope. Removing support for cross-scope is necessary for certain compile-time assumptions (like class constants) to prevent unexpected results
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Mar 17 11:00:01 2026 UTC