Skip to content

Instantly share code, notes, and snippets.

@NattyNarwhal
Created September 10, 2020 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NattyNarwhal/09679e177b11de22aeceaaffdc62012b to your computer and use it in GitHub Desktop.
Save NattyNarwhal/09679e177b11de22aeceaaffdc62012b to your computer and use it in GitHub Desktop.
opcache misoptimization bug
$_main: ; (lines=11, args=0, vars=2, tmps=6)
; (before optimizer)
; /home/calvin/test/gautier.php:1-42
L0 (37): INIT_FCALL 0 160 string("mydb2connect")
L1 (37): V2 = DO_UCALL
L2 (37): ASSIGN CV0($myDb2) V2
L3 (39): INIT_FCALL 1 368 string("mycallproc")
L4 (39): SEND_VAR CV0($myDb2) 1
L5 (39): V4 = DO_UCALL
L6 (39): ASSIGN CV1($resultStmt) V4
L7 (41): T6 = CONCAT string("Résultat : ") CV1($resultStmt)
L8 (41): T7 = CONCAT T6 string("
")
L9 (41): ECHO T7
L10 (42): RETURN int(1)
myDB2Connect: ; (lines=10, args=0, vars=2, tmps=3)
; (before optimizer)
; /home/calvin/test/gautier.php:4-10
L0 (6): ASSIGN CV0($options) array(...)
L1 (8): INIT_FCALL 4 144 string("db2_connect")
L2 (8): SEND_VAL string("*LOCAL") 1
L3 (8): SEND_VAL string("CALVIN") 2
L4 (8): SEND_VAL string("<elided>") 3
L5 (8): SEND_VAR CV0($options) 4
L6 (8): V3 = DO_ICALL
L7 (8): ASSIGN CV1($db2) V3
L8 (9): RETURN CV1($db2)
L9 (10): RETURN null
myCallProc: ; (lines=34, args=1, vars=7, tmps=11)
; (before optimizer)
; /home/calvin/test/gautier.php:12-35
L0 (12): CV0($ldb2) = RECV 1
L1 (21): ASSIGN CV1($PARM1) string("test")
L2 (22): ASSIGN CV2($PARM2) string("")
L3 (23): ASSIGN CV3($PARM3) string("")
L4 (24): ASSIGN CV4($sql) string("CALL CALVIN.PGMPHP ( ? , ? , ? )")
L5 (25): INIT_FCALL 2 112 string("db2_prepare")
L6 (25): SEND_VAR CV0($ldb2) 1
L7 (25): SEND_VAR CV4($sql) 2
L8 (25): V11 = DO_ICALL
L9 (25): ASSIGN CV5($stmt) V11
L10 (27): INIT_FCALL 4 144 string("db2_bind_param")
L11 (27): SEND_VAR CV5($stmt) 1
L12 (27): SEND_VAL int(1) 2
L13 (27): SEND_VAL string("PARM1") 3
L14 (27): SEND_VAL int(1) 4
L15 (27): DO_ICALL
L16 (28): INIT_FCALL 4 144 string("db2_bind_param")
L17 (28): SEND_VAR CV5($stmt) 1
L18 (28): SEND_VAL int(2) 2
L19 (28): SEND_VAL string("PARM2") 3
L20 (28): SEND_VAL int(2) 4
L21 (28): DO_ICALL
L22 (29): INIT_FCALL 4 144 string("db2_bind_param")
L23 (29): SEND_VAR CV5($stmt) 1
L24 (29): SEND_VAL int(3) 2
L25 (29): SEND_VAL string("PARM3") 3
L26 (29): SEND_VAL int(2) 4
L27 (29): DO_ICALL
L28 (31): INIT_FCALL 1 96 string("db2_execute")
L29 (31): SEND_VAR CV5($stmt) 1
L30 (31): V16 = DO_ICALL
L31 (31): ASSIGN CV6($resExec) V16
L32 (33): RETURN CV3($PARM3)
L33 (35): RETURN null
$_main: ; (lines=11, args=0, vars=2, tmps=2)
; (after optimizer)
; /home/calvin/test/gautier.php:1-42
L0 (37): INIT_FCALL 0 128 string("mydb2connect")
L1 (37): V2 = DO_UCALL
L2 (37): ASSIGN CV0($myDb2) V2
L3 (39): INIT_FCALL 1 208 string("mycallproc")
L4 (39): SEND_VAR CV0($myDb2) 1
L5 (39): V2 = DO_UCALL
L6 (39): ASSIGN CV1($resultStmt) V2
L7 (41): T3 = CONCAT string("Résultat : ") CV1($resultStmt)
L8 (41): T2 = CONCAT T3 string("
")
L9 (41): ECHO T2
L10 (42): RETURN int(1)
myDB2Connect: ; (lines=9, args=0, vars=2, tmps=1)
; (after optimizer)
; /home/calvin/test/gautier.php:4-10
L0 (6): ASSIGN CV0($options) array(...)
L1 (8): INIT_FCALL 4 144 string("db2_connect")
L2 (8): SEND_VAL string("*LOCAL") 1
L3 (8): SEND_VAL string("CALVIN") 2
L4 (8): SEND_VAL string("<elided>") 3
L5 (8): SEND_VAR CV0($options) 4
L6 (8): V2 = DO_ICALL
L7 (8): ASSIGN CV1($db2) V2
L8 (9): RETURN CV1($db2)
myCallProc: ; (lines=33, args=1, vars=7, tmps=1)
; (after optimizer)
; /home/calvin/test/gautier.php:12-35
L0 (12): CV0($ldb2) = RECV 1
L1 (21): ASSIGN CV1($PARM1) string("test")
L2 (22): ASSIGN CV2($PARM2) string("")
L3 (23): ASSIGN CV3($PARM3) string("")
L4 (24): ASSIGN CV4($sql) string("CALL CALVIN.PGMPHP ( ? , ? , ? )")
L5 (25): INIT_FCALL 2 112 string("db2_prepare")
L6 (25): SEND_VAR CV0($ldb2) 1
L7 (25): SEND_VAR CV4($sql) 2
L8 (25): V7 = DO_ICALL
L9 (25): ASSIGN CV5($stmt) V7
L10 (27): INIT_FCALL 4 144 string("db2_bind_param")
L11 (27): SEND_VAR CV5($stmt) 1
L12 (27): SEND_VAL int(1) 2
L13 (27): SEND_VAL string("PARM1") 3
L14 (27): SEND_VAL int(1) 4
L15 (27): DO_ICALL
L16 (28): INIT_FCALL 4 144 string("db2_bind_param")
L17 (28): SEND_VAR CV5($stmt) 1
L18 (28): SEND_VAL int(2) 2
L19 (28): SEND_VAL string("PARM2") 3
L20 (28): SEND_VAL int(2) 4
L21 (28): DO_ICALL
L22 (29): INIT_FCALL 4 144 string("db2_bind_param")
L23 (29): SEND_VAR CV5($stmt) 1
L24 (29): SEND_VAL int(3) 2
L25 (29): SEND_VAL string("PARM3") 3
L26 (29): SEND_VAL int(2) 4
L27 (29): DO_ICALL
L28 (31): INIT_FCALL 1 96 string("db2_execute")
L29 (31): SEND_VAR CV5($stmt) 1
L30 (31): V7 = DO_ICALL
L31 (31): ASSIGN CV6($resExec) V7
L32 (33): RETURN CV3($PARM3)
$_main: ; (lines=11, args=0, vars=2, tmps=6)
; (before optimizer)
; /home/calvin/test/gautier.php:1-42
L0 (37): INIT_FCALL 0 160 string("mydb2connect")
L1 (37): V2 = DO_UCALL
L2 (37): ASSIGN CV0($myDb2) V2
L3 (39): INIT_FCALL 1 368 string("mycallproc")
L4 (39): SEND_VAR CV0($myDb2) 1
L5 (39): V4 = DO_UCALL
L6 (39): ASSIGN CV1($resultStmt) V4
L7 (41): T6 = CONCAT string("Résultat : ") CV1($resultStmt)
L8 (41): T7 = CONCAT T6 string("
")
L9 (41): ECHO T7
L10 (42): RETURN int(1)
myDB2Connect: ; (lines=10, args=0, vars=2, tmps=3)
; (before optimizer)
; /home/calvin/test/gautier.php:4-10
L0 (6): ASSIGN CV0($options) array(...)
L1 (8): INIT_FCALL 4 144 string("db2_connect")
L2 (8): SEND_VAL string("*LOCAL") 1
L3 (8): SEND_VAL string("CALVIN") 2
L4 (8): SEND_VAL string("<elided>") 3
L5 (8): SEND_VAR CV0($options) 4
L6 (8): V3 = DO_ICALL
L7 (8): ASSIGN CV1($db2) V3
L8 (9): RETURN CV1($db2)
L9 (10): RETURN null
myCallProc: ; (lines=34, args=1, vars=7, tmps=11)
; (before optimizer)
; /home/calvin/test/gautier.php:12-35
L0 (12): CV0($ldb2) = RECV 1
L1 (21): ASSIGN CV1($PARM1) string("test")
L2 (22): ASSIGN CV2($PARM2) string("")
L3 (23): ASSIGN CV3($PARM3) string("")
L4 (24): ASSIGN CV4($sql) string("CALL CALVIN.PGMPHP ( ? , ? , ? )")
L5 (25): INIT_FCALL 2 112 string("db2_prepare")
L6 (25): SEND_VAR CV0($ldb2) 1
L7 (25): SEND_VAR CV4($sql) 2
L8 (25): V11 = DO_ICALL
L9 (25): ASSIGN CV5($stmt) V11
L10 (27): INIT_FCALL 4 144 string("db2_bind_param")
L11 (27): SEND_VAR CV5($stmt) 1
L12 (27): SEND_VAL int(1) 2
L13 (27): SEND_VAL string("PARM1") 3
L14 (27): SEND_VAL int(1) 4
L15 (27): DO_ICALL
L16 (28): INIT_FCALL 4 144 string("db2_bind_param")
L17 (28): SEND_VAR CV5($stmt) 1
L18 (28): SEND_VAL int(2) 2
L19 (28): SEND_VAL string("PARM2") 3
L20 (28): SEND_VAL int(2) 4
L21 (28): DO_ICALL
L22 (29): INIT_FCALL 4 144 string("db2_bind_param")
L23 (29): SEND_VAR CV5($stmt) 1
L24 (29): SEND_VAL int(3) 2
L25 (29): SEND_VAL string("PARM3") 3
L26 (29): SEND_VAL int(2) 4
L27 (29): DO_ICALL
L28 (31): INIT_FCALL 1 96 string("db2_execute")
L29 (31): SEND_VAR CV5($stmt) 1
L30 (31): V16 = DO_ICALL
L31 (31): ASSIGN CV6($resExec) V16
L32 (33): RETURN CV3($PARM3)
L33 (35): RETURN null
$_main: ; (lines=11, args=0, vars=2, tmps=2)
; (after optimizer)
; /home/calvin/test/gautier.php:1-42
L0 (37): INIT_FCALL 0 112 string("mydb2connect")
L1 (37): V2 = DO_UCALL
L2 (37): ASSIGN CV0($myDb2) V2
L3 (39): INIT_FCALL 1 144 string("mycallproc")
L4 (39): SEND_VAR CV0($myDb2) 1
L5 (39): V2 = DO_UCALL
L6 (39): ASSIGN CV1($resultStmt) V2
L7 (41): T3 = CONCAT string("Résultat : ") CV1($resultStmt)
L8 (41): T2 = FAST_CONCAT T3 string("
")
L9 (41): ECHO T2
L10 (42): RETURN int(1)
myDB2Connect: ; (lines=8, args=0, vars=1, tmps=1)
; (after optimizer)
; /home/calvin/test/gautier.php:4-10
L0 (8): INIT_FCALL 4 144 string("db2_connect")
L1 (8): SEND_VAL string("*LOCAL") 1
L2 (8): SEND_VAL string("CALVIN") 2
L3 (8): SEND_VAL string("<elided>") 3
L4 (8): SEND_VAL array(...) 4
L5 (8): V1 = DO_ICALL
L6 (8): CV0($db2) = QM_ASSIGN V1
L7 (9): RETURN CV0($db2)
myCallProc: ; (lines=29, args=1, vars=3, tmps=1)
; (after optimizer)
; /home/calvin/test/gautier.php:12-35
L0 (12): CV0($ldb2) = RECV 1
L1 (25): INIT_FCALL 2 112 string("db2_prepare")
L2 (25): SEND_VAR CV0($ldb2) 1
L3 (25): SEND_VAL string("CALL CALVIN.PGMPHP ( ? , ? , ? )") 2
L4 (25): V3 = DO_ICALL
L5 (25): CV1($stmt) = QM_ASSIGN V3
L6 (27): INIT_FCALL 4 144 string("db2_bind_param")
L7 (27): SEND_VAR CV1($stmt) 1
L8 (27): SEND_VAL int(1) 2
L9 (27): SEND_VAL string("PARM1") 3
L10 (27): SEND_VAL int(1) 4
L11 (27): DO_ICALL
L12 (28): INIT_FCALL 4 144 string("db2_bind_param")
L13 (28): SEND_VAR CV1($stmt) 1
L14 (28): SEND_VAL int(2) 2
L15 (28): SEND_VAL string("PARM2") 3
L16 (28): SEND_VAL int(2) 4
L17 (28): DO_ICALL
L18 (29): INIT_FCALL 4 144 string("db2_bind_param")
L19 (29): SEND_VAR CV1($stmt) 1
L20 (29): SEND_VAL int(3) 2
L21 (29): SEND_VAL string("PARM3") 3
L22 (29): SEND_VAL int(2) 4
L23 (29): DO_ICALL
L24 (31): INIT_FCALL 1 96 string("db2_execute")
L25 (31): SEND_VAR CV1($stmt) 1
L26 (31): V3 = DO_ICALL
L27 (31): CV2($resExec) = QM_ASSIGN V3
L28 (33): RETURN string("")
PHP Warning: db2_execute(): Value Not Bound in /home/calvin/test/gautier.php on line 31
PHP Warning: db2_execute(): Binding Error 3 in /home/calvin/test/gautier.php on line 31
--- 0x7FFEBFDF.output 2020-09-10 11:07:32.000000000 +0000
+++ 0x7FFEBFFF.output 2020-09-10 11:07:27.000000000 +0000
@@ -70,65 +70,62 @@
$_main: ; (lines=11, args=0, vars=2, tmps=2)
; (after optimizer)
; /home/calvin/test/gautier.php:1-42
-L0 (37): INIT_FCALL 0 128 string("mydb2connect")
+L0 (37): INIT_FCALL 0 112 string("mydb2connect")
L1 (37): V2 = DO_UCALL
L2 (37): ASSIGN CV0($myDb2) V2
-L3 (39): INIT_FCALL 1 208 string("mycallproc")
+L3 (39): INIT_FCALL 1 144 string("mycallproc")
L4 (39): SEND_VAR CV0($myDb2) 1
L5 (39): V2 = DO_UCALL
L6 (39): ASSIGN CV1($resultStmt) V2
L7 (41): T3 = CONCAT string("Résultat : ") CV1($resultStmt)
-L8 (41): T2 = CONCAT T3 string("
+L8 (41): T2 = FAST_CONCAT T3 string("
")
L9 (41): ECHO T2
L10 (42): RETURN int(1)
-myDB2Connect: ; (lines=9, args=0, vars=2, tmps=1)
+myDB2Connect: ; (lines=8, args=0, vars=1, tmps=1)
; (after optimizer)
; /home/calvin/test/gautier.php:4-10
-L0 (6): ASSIGN CV0($options) array(...)
-L1 (8): INIT_FCALL 4 144 string("db2_connect")
-L2 (8): SEND_VAL string("*LOCAL") 1
-L3 (8): SEND_VAL string("CALVIN") 2
-L4 (8): SEND_VAL string("<elided>") 3
-L5 (8): SEND_VAR CV0($options) 4
-L6 (8): V2 = DO_ICALL
-L7 (8): ASSIGN CV1($db2) V2
-L8 (9): RETURN CV1($db2)
+L0 (8): INIT_FCALL 4 144 string("db2_connect")
+L1 (8): SEND_VAL string("*LOCAL") 1
+L2 (8): SEND_VAL string("CALVIN") 2
+L3 (8): SEND_VAL string("<elided>") 3
+L4 (8): SEND_VAL array(...) 4
+L5 (8): V1 = DO_ICALL
+L6 (8): CV0($db2) = QM_ASSIGN V1
+L7 (9): RETURN CV0($db2)
-myCallProc: ; (lines=33, args=1, vars=7, tmps=1)
+myCallProc: ; (lines=29, args=1, vars=3, tmps=1)
; (after optimizer)
; /home/calvin/test/gautier.php:12-35
L0 (12): CV0($ldb2) = RECV 1
-L1 (21): ASSIGN CV1($PARM1) string("test")
-L2 (22): ASSIGN CV2($PARM2) string("")
-L3 (23): ASSIGN CV3($PARM3) string("")
-L4 (24): ASSIGN CV4($sql) string("CALL CALVIN.PGMPHP ( ? , ? , ? )")
-L5 (25): INIT_FCALL 2 112 string("db2_prepare")
-L6 (25): SEND_VAR CV0($ldb2) 1
-L7 (25): SEND_VAR CV4($sql) 2
-L8 (25): V7 = DO_ICALL
-L9 (25): ASSIGN CV5($stmt) V7
-L10 (27): INIT_FCALL 4 144 string("db2_bind_param")
-L11 (27): SEND_VAR CV5($stmt) 1
-L12 (27): SEND_VAL int(1) 2
-L13 (27): SEND_VAL string("PARM1") 3
-L14 (27): SEND_VAL int(1) 4
-L15 (27): DO_ICALL
-L16 (28): INIT_FCALL 4 144 string("db2_bind_param")
-L17 (28): SEND_VAR CV5($stmt) 1
-L18 (28): SEND_VAL int(2) 2
-L19 (28): SEND_VAL string("PARM2") 3
-L20 (28): SEND_VAL int(2) 4
-L21 (28): DO_ICALL
-L22 (29): INIT_FCALL 4 144 string("db2_bind_param")
-L23 (29): SEND_VAR CV5($stmt) 1
-L24 (29): SEND_VAL int(3) 2
-L25 (29): SEND_VAL string("PARM3") 3
-L26 (29): SEND_VAL int(2) 4
-L27 (29): DO_ICALL
-L28 (31): INIT_FCALL 1 96 string("db2_execute")
-L29 (31): SEND_VAR CV5($stmt) 1
-L30 (31): V7 = DO_ICALL
-L31 (31): ASSIGN CV6($resExec) V7
-L32 (33): RETURN CV3($PARM3)
+L1 (25): INIT_FCALL 2 112 string("db2_prepare")
+L2 (25): SEND_VAR CV0($ldb2) 1
+L3 (25): SEND_VAL string("CALL CALVIN.PGMPHP ( ? , ? , ? )") 2
+L4 (25): V3 = DO_ICALL
+L5 (25): CV1($stmt) = QM_ASSIGN V3
+L6 (27): INIT_FCALL 4 144 string("db2_bind_param")
+L7 (27): SEND_VAR CV1($stmt) 1
+L8 (27): SEND_VAL int(1) 2
+L9 (27): SEND_VAL string("PARM1") 3
+L10 (27): SEND_VAL int(1) 4
+L11 (27): DO_ICALL
+L12 (28): INIT_FCALL 4 144 string("db2_bind_param")
+L13 (28): SEND_VAR CV1($stmt) 1
+L14 (28): SEND_VAL int(2) 2
+L15 (28): SEND_VAL string("PARM2") 3
+L16 (28): SEND_VAL int(2) 4
+L17 (28): DO_ICALL
+L18 (29): INIT_FCALL 4 144 string("db2_bind_param")
+L19 (29): SEND_VAR CV1($stmt) 1
+L20 (29): SEND_VAL int(3) 2
+L21 (29): SEND_VAL string("PARM3") 3
+L22 (29): SEND_VAL int(2) 4
+L23 (29): DO_ICALL
+L24 (31): INIT_FCALL 1 96 string("db2_execute")
+L25 (31): SEND_VAR CV1($stmt) 1
+L26 (31): V3 = DO_ICALL
+L27 (31): CV2($resExec) = QM_ASSIGN V3
+L28 (33): RETURN string("")
+PHP Warning: db2_execute(): Value Not Bound in /home/calvin/test/gautier.php on line 31
+PHP Warning: db2_execute(): Binding Error 3 in /home/calvin/test/gautier.php on line 31
<?php
function myDB2Connect()
{
$options = array('i5_dbcs_alloc'=>1);
$db2 = db2_connect('*LOCAL', 'CALVIN', '<elided>', $options);
return $db2;
}
function myCallProc($ldb2)
{
//Without this line, execute failed with :
//Warning: db2_execute(): Value Not Bound in myscript.php on line xx
//Warning: db2_execute(): Binding Error 3 in myscript.php on line xx
//global $PARM1,$PARM2,$PARM3;
$PARM1 = 'test';
$PARM2 = '';
$PARM3 = '';
$sql = 'CALL CALVIN.PGMPHP ( ? , ? , ? )';
$stmt = db2_prepare($ldb2 , $sql);
db2_bind_param($stmt, 1, 'PARM1', DB2_PARAM_IN);
db2_bind_param($stmt, 2, 'PARM2', DB2_PARAM_OUT);
db2_bind_param($stmt, 3, 'PARM3', DB2_PARAM_OUT);
$resExec = db2_execute($stmt);
return $PARM3;
}
$myDb2 = myDB2Connect();
$resultStmt = myCallProc($myDb2);
echo 'Résultat : '.$resultStmt . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment