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: 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:
right, but it can't break something because the function can accept
references.
It's just unnecessary copying, but I suppose that it's a very rare case.
Previous Comments:
------------------------------------------------------------------------
[2010-10-14 08:28:31] cataphract@php.net
Ah right, the part after the if in line #854 is still executed.
You also seem to have missed an implication of in your commit, because
with a value + SEND_PREFER_REF, the newly separated value will be have
is_ref set to 1 by that part in #880 - #882.
The test script in the report gives this result:
direct call
[0x43436c0, refcount=1] int(1)
[0x4343d20, refcount=2] &string(1) "a"
[0x4343710, refcount=1] int(7)
call via zend_call_function
[0x43436c0, refcount=3] int(1)
[0x4343d20, refcount=4] &string(1) "a"
[0x43426d8, refcount=2] &int(7)
------------------------------------------------------------------------
[2010-10-14 08:11:34] dmitry@php.net
I agree that separation might be omitted, but with your patch we just
convert value into reference without separation. In case of no
separation we also have to prevent Z_SET_ISREF_PP(fci->params[i]);
------------------------------------------------------------------------
[2010-10-14 03:11:26] cataphract@php.net
That does it.
On a minor note, the fix does an unnecessary zval separation. The need
to separate the zval if !fci->no_separation, the zval is not a reference
and the function expects a reference is because, presumably, if the
target function expects a reference, it may assume it has one and then
change the zval without separation. However, if it *prefers* a
reference, it presumably doesn't rely on having one and it's
(presumably...) safe not to separate the zval (see
http://bugs.php.net/patch-display.php?bug=52939&patch=zend_call_user_function_prefer_ref&revision=1285639039
)
------------------------------------------------------------------------
[2010-10-13 10:52:13] dmitry@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.
------------------------------------------------------------------------
[2010-10-13 10:51:41] dmitry@php.net
Automatic comment from SVN on behalf of dmitry
Revision: http://svn.php.net/viewvc/?view=revision&revision=304364
Log: Fixed bug #52939 (zend_call_function does not respect
ZEND_SEND_PREFER_REF)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=52939
--
Edit this bug report at http://bugs.php.net/bug.php?id=52939&edit=1