|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-06-05 17:14 UTC] lisio at bk dot ru
Description:
------------
After calling the function using a non-defined variable variable as a second parameter the interpreter goes crazy. Just reproduce the script on any of 5.3.* versions of PHP.
Test script:
---------------
<?php
a(0,$$var);
$temp1=1;
$temp2=2;
echo $temp1;
function a($b,$c) {}
?>
Expected result:
----------------
1
Actual result:
--------------
2
Patchespatch-dont-ruine-uninitialized-ptr (last revision 2010-06-08 02:40 UTC by boldin dot pavel at gmail dot com)patch-bug-52001-tests (last revision 2010-06-07 23:27 UTC by boldin dot pavel at gmail dot com) patch-zend-fetch-make-ref-uninitialized-ptr (last revision 2010-06-06 17:03 UTC by boldin dot pavel at gmail dot com) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 11:00:01 2025 UTC |
<?php $test = 0; $var = 'test'; f(0, $$var); $x = 1; $y = 2; echo $x; function f($a, $b) {} ?> In this case I receive correct result.Version without bug: (gdb) zend_send_by_var_helper_SPEC_VAR (execute_data=0x88a28d0) at /home/davinchi/php-5.3.2/Zend/zend_vm_execute.h:8257 8257 varptr = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); (gdb) 8259 if (varptr == &EG(uninitialized_zval)) { (gdb) p varptr $24 = (zval *) 0x877fd04 (gdb) p &executor_globals.uninitialized_zval $25 = (zval *) 0x877fd04 (gdb) p executor_globals.uninitialized_zval_ptr $26 = (zval *) 0x877fd04 And version with bug: zend_send_by_var_helper_SPEC_VAR (execute_data=0x88a28d0) at /home/davinchi/php-5.3.2/Zend/zend_vm_execute.h:8254 8254 zend_op *opline = EX(opline); (gdb) 8257 varptr = _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC); (gdb) n 8259 if (varptr == &EG(uninitialized_zval)) { (gdb) p varptr $27 = (zval *) 0x8876d8c (gdb) p &executor_globals.uninitialized_zval $28 = (zval *) 0x877fd04 (gdb) p executor_globals.uninitialized_zval_ptr $29 = (zval *) 0x8876d8c See that uninitialized_zval_ptr dont pointers to the uninitialized_zval at all!Finally: bug is at if (opline->extended_value & ZEND_FETCH_MAKE_REF) { SEPARATE_ZVAL_TO_MAKE_IS_REF(retval); } SEPARATE_ZVAL_TO_MAKE_IS_REF seems to ruine *retval (which is executor_globals.uninitialized_ptr). Then this leads to incorrectly working zend_send_by_var_helper and incorrect referencing count in zend_assign_to_variable. Trying to patch now.Zend/zend_compile.c 1066: if (opline && type == BP_VAR_W && arg_offset) { opline->extended_value = ZEND_FETCH_MAKE_REF; } Is not this bug too? ZEND_FETCH_MAKE_REF is not set for first (arg_offset == 0) arg?