Bug #69159 [Opn]: Opcache causes problem when passing a variable variable to a function

From: Date: Wed, 04 Mar 2015 06:19:41 +0000
Subject: Bug #69159 [Opn]: Opcache causes problem when passing a variable variable to a function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191119@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69159&edit=1

 ID:                 69159
 Updated by:         laruence@php.net
 Reported by:        seb at rootsandrain dot com
 Summary:            Opcache causes problem when passing a variable
                     variable to a function
 Status:             Open
 Type:               Bug
 Package:            opcache
 Operating System:   CentOS
 PHP Version:        5.6.6
-Assigned To:        
+Assigned To:        laruence
 Block user comment: N
 Private report:     N

 New Comment:

it should fixes the problem.


Previous Comments:
------------------------------------------------------------------------
[2015-03-04 06:19:17] laruence@php.net

could you verify this fix works?

diff --git a/ext/opcache/Optimizer/optimize_func_calls.c
b/ext/opcache/Optimizer/optimize_func_calls.c
index 14f8255..17136ba 100644
--- a/ext/opcache/Optimizer/optimize_func_calls.c
+++ b/ext/opcache/Optimizer/optimize_func_calls.c
@@ -82,10 +82,10 @@ static void optimize_func_calls(zend_op_array *op_array, zend_persistent_script
 			case ZEND_FETCH_DIM_FUNC_ARG:
 				if (call_stack[call - 1].func) {
 					if (ARG_SHOULD_BE_SENT_BY_REF(call_stack[call - 1].func, (opline->extended_value
 & ZEND_FETCH_ARG_MASK))) {
-						opline->extended_value = 0;
-						opline->opcode -= 9;
+						opline->extended_value = (opline->opcode == ZEND_FETCH_FUNC_ARG)? ZEND_F
ETCH_LOCAL : 0;
+						opline->opcode -= 9;
 					} else {
-						opline->extended_value = 0;
+						opline->extended_value = (opline->opcode == ZEND_FETCH_FUNC_ARG)? ZEND_F
ETCH_LOCAL : 0;
 						opline->opcode -= 12;
 					}
 				}

thanks

------------------------------------------------------------------------
[2015-03-02 15:09:06] seb at rootsandrain dot com

Description:
------------
After upgrading from 5.5.22 to 5.6.6 the script failed to operate correctly, churning out
"Notice: undefined variable" errors on the function call line.

Disabling opcache fixes the problem.

Sadly the short version I've posted here doesn't appear to exhibit the problem, and I
don't have time to anonymise the much larger section of code that's been breaking.

Nevertheless, it was 100% the call to "myFunction" that was giving a Notice undefined
variable error.

Test script:
---------------
$i=1;
${"sR{$i}S1"} = 'hello';
${"nR{$i}S1P"} = 'world';

myFunction(${"sR{$i}S1"}, ${"nR{$i}S1P"});

function myFunction($x, $y) {
    echo "$x $y";
}

Expected result:
----------------
echos

"hello world"

Actual result:
--------------
Notice: undefined variable


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



--
Edit this bug report at https://bugs.php.net/bug.php?id=69159&edit=1


Thread (4 messages)

« previous php.bugs (#191119) next »