Bug #52939 [Asn->Csd]: zend_call_function does not respect ZEND_SEND_PREFER_REF

From: Date: Wed, 13 Oct 2010 08:52:14 +0000
Subject: Bug #52939 [Asn->Csd]: zend_call_function does not respect ZEND_SEND_PREFER_REF
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-155141@lists.php.net to get a copy of this message
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-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)

------------------------------------------------------------------------
[2010-10-12 23:49:25] cataphract@php.net

This last test is exactly the same thing, and still gives an error. The
only thing that would be different would be

call_user_func_array("array_multisort", array(array("row1" => 2,
"row2"
=> 1)));

because now the inner array refcount would be 1 and in that case
zend_call_function flips is_ref.

This code

$args = array(array("row1" => 2, "row2" => 1));
call_user_func_array("array_multisort", $args);

should still pass $args[0] by value. The fact that it can't be modified
is irrelevant; array_multisort explicitly declares it can accept a value
(probably because it can accept multiple arrays and one may want to
modify only some).

------------------------------------------------------------------------
[2010-10-12 20:48:50] dmitry@php.net

Note that array($ar1) creates an array with a copy of $ar1 and its
modification doesn't affect the original $ar1 value. Probably the proper
test would be

<?php
$args = array(array("row1" => 2, "row2" => 1));
call_user_func_array("array_multisort", $args);
var_dump($args[0]);
?>

I'll check if it works tomorrow. But anyway it's not the thing you like.

------------------------------------------------------------------------
[2010-10-12 16:15:56] cataphract@php.net

The test you added doesn't test the issue.

The problem is not zend_call_function + ZEND_SEND_PREF_REF not accepting
reference; it's not accepting values. This is the correct test:

<?php
	var_dump(array_multisort(array("row1" => 2, "row2" => 1)));
	
	$ar1 = array("row1" => 2, "row2" => 1);
	var_dump(call_user_func_array("array_multisort", array($ar1)));
	var_dump($ar1);

The "normal" call works, because even though it's a value, it's accepted
because of ZEND_SEND_PREFER_REF. The call via call_user_func_array still
fails because of this bug.

------------------------------------------------------------------------
[2010-10-12 09:39:32] 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.



------------------------------------------------------------------------


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


Thread (13 messages)

« previous php.bugs (#155141) next »