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: bwoebi@php.net 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] bwoebi@php.net
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] bwoebi@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: bwoebi
 [2015-10-03 23:43 UTC] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
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] bwoebi@php.net
-Status: Assigned +Status: Closed
 [2015-10-03 23:44 UTC] bwoebi@php.net
Automatic comment on behalf of bobwei9@hotmail.com
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] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
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] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
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] ab@php.net
Automatic comment on behalf of dmitry@zend.com
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] ab@php.net
Automatic comment on behalf of dmitry@zend.com
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] ab@php.net
Automatic comment on behalf of bobwei9@hotmail.com
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] davey@php.net
Automatic comment on behalf of dmitry@zend.com
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] davey@php.net
Automatic comment on behalf of dmitry@zend.com
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] davey@php.net
Automatic comment on behalf of bobwei9@hotmail.com
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 05 19:01:30 2024 UTC