Edit report at http://bugs.php.net/bug.php?id=52939&edit=1
ID: 52939
Updated by: dmitry@php.net
Reported by: cataphract@php.net
Summary: zend_call_function does not respect
ZEND_SEND_PREFER_REF
-Status: Assigned
+Status: Closed
Type: Bug
Package: Scripting Engine problem
Operating System: Windows 7 x64
PHP Version: trunk-SVN-2010-09-28 (SVN)
Assigned To: dmitry
Block user comment: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2010-10-12 09:39:21] dmitry@php.net
The bug is already fixed in SVN (see Zend/tests/bug52939.phpt)
------------------------------------------------------------------------
[2010-09-28 03:57:19] cataphract@php.net
The following patch has been added/updated:
Patch Name: zend_call_user_function_prefer_ref
Revision: 1285639039
URL:
http://bugs.php.net/patch-display.php?bug=52939&patch=zend_call_user_function_prefer_ref&revision=1285639039
------------------------------------------------------------------------
[2010-09-28 03:50:12] cataphract@php.net
The following patch has been added/updated:
Patch Name: zend_call_user_function_prefer_ref
Revision: 1285638612
URL:
http://bugs.php.net/patch-display.php?bug=52939&patch=zend_call_user_function_prefer_ref&revision=1285638612
------------------------------------------------------------------------
[2010-09-28 03:44:24] cataphract@php.net
Description:
------------
The function zend_call_function interprets ZEND_SEND_PREFER_REF as if it
were ZEND_SEND_BY_REF.
Test script:
---------------
<?php
$a = 'a';
$b = 7;
echo "direct call\n";
test_passing(1, $a, 7);
echo "call via zend_call_function\n";
//separate definition to put the refcount of the third parameter=2.
//If it were 1, zend_call_function would use its special "convert
//into reference" case and wouldn't error out
//i.e., this works: call_user_func_array('test_passing', array(1, &$a,
7));
$arguments = array(1, &$a, 7);
call_user_func_array('test_passing', $arguments);
------
PHP_FUNCTION(test_passing)
{
zval ***params;
unsigned param_count;
int i;
param_count = ZEND_NUM_ARGS();
params = emalloc(param_count * sizeof *params);
for (i = 0; i < (int) param_count; i++) {
params[i] = (zval **) (zend_vm_stack_top(TSRMLS_C) - 1 -
(param_count - i));
php_printf("[%p, refcount=%u] ", *params[i],
(*params[i])->refcount__gc);
php_var_dump(params[i], 0 TSRMLS_CC);
}
efree(params);
}
ZEND_BEGIN_ARG_INFO_EX(arginfo_test_passing, 0, 0, 3)
ZEND_ARG_INFO(0, req_pass_by_val)
ZEND_ARG_INFO(1, req_pass_by_ref)
ZEND_ARG_INFO(2, req_prefer_ pass_by_ref)
ZEND_END_ARG_INFO()
Expected result:
----------------
Both calls would be successful.
Actual result:
--------------
Only the direct call is successful:
direct call
[0x5ddbed0, refcount=1] int(1)
[0x5ddc530, refcount=2] &string(1) "a"
[0x5ddbf20, refcount=1] int(7)
call via zend_call_function
PHP Warning: Parameter 3 to test_passing() expected to be a reference,
value gi
ven in - on line 12
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52939&edit=1