From: cataphract Operating system: Windows 7 x64 PHP version: trunk-SVN-2010-09-28 (SVN) Package: Scripting Engine problem Bug Type: Bug Bug description:zend_call_function does not respect ZEND_SEND_PREFER_REF
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 bug report at http://bugs.php.net/bug.php?id=52939&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52939&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52939&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52939&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52939&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52939&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52939&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52939&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52939&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52939&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52939&r=support Expected behavior: http://bugs.php.net/fix.php?id=52939&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52939&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52939&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52939&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52939&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52939&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52939&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52939&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52939&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52939&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52939&r=mysqlcfg