php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52539 Calling function from rebound Closure causes crash
Submitted: 2010-08-05 09:34 UTC Modified: 2010-08-08 17:06 UTC
From: cataphract@php.net Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: trunk-SVN-2010-08-05 (SVN) OS: Windows
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: cataphract@php.net
New email:
PHP Version: OS:

 

 [2010-08-05 09:34 UTC] cataphract@php.net
Description:
------------
Calling a function in a rebound closure causes a crash.

This seems to be caused by dmitry's optimizations because this fixes the issue:
#define CACHED_PTR(num) 0.

Test script:
---------------
class foo {
	static function getClosure() {
		return static function () {
			//causes a crash (fbc not properly defined) in call after rebinding
			echo get_called_class(), "\n";
		};
	}
}
 
class subFoo { }
 
$c = foo::getClosure();
$c(); //foo
$c = $c->bindTo(new subFoo());
$c(); //crash

Expected result:
----------------
No crash.

Actual result:
--------------
>	php5ts_debug.dll!zend_do_fcall_common_helper_SPEC(_zend_execute_data * execute_data=0x025d2298, void * * * tsrm_ls=0x02784bf8)  Line 302 + 0x3 bytes	C
 	php5ts_debug.dll!ZEND_DO_FCALL_SPEC_CONST_HANDLER(_zend_execute_data * execute_data=0x025d2298, void * * * tsrm_ls=0x02784bf8)  Line 1721	C
 	php5ts_debug.dll!execute(_zend_op_array * op_array=0x025f23c8, void * * * tsrm_ls=0x02784bf8)  Line 136 + 0x11 bytes	C
 	php5ts_debug.dll!zend_execute_scripts(int type=8, void * * * tsrm_ls=0x02784bf8, _zval_struct * * retval=0x00000000, int file_count=3, ...)  Line 1193 + 0x21 bytes	C
 	php5ts_debug.dll!php_execute_script(_zend_file_handle * primary_file=0x00aaf7b0, void * * * tsrm_ls=0x02784bf8)  Line 2330 + 0x1b bytes	C
 	php.exe!main(int argc=2, char * * argv=0x02784af8)  Line 1252 + 0x13 bytes	C


Patches

patch_closures_rebind (last revision 2010-08-08 14:30 UTC by cataphract@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-06 03:53 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: dmitry
 [2010-08-08 16:30 UTC] cataphract@php.net
The following patch has been added/updated:

Patch Name: patch_closures_rebind
Revision:   1281277806
URL:        http://bugs.php.net/patch-display.php?bug=52539&patch=patch_closures_rebind&revision=1281277806
 [2010-08-08 17:06 UTC] felipe@php.net
Automatic comment from SVN on behalf of felipe
Revision: http://svn.php.net/viewvc/?view=revision&revision=301990
Log: - Fixed bug #52539 (Calling function from rebound Closure causes crash)
 [2010-08-08 17:06 UTC] felipe@php.net
-Status: Assigned +Status: Closed
 [2010-08-08 17:06 UTC] felipe@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 14:01:36 2025 UTC