-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix DFG construction for VERIFY_RETURN
`use` only contains uses prior to definition. This was not honoured for VERIFY_RETURN with a temporary operand. The test case only breaks on PHP 7.2.
- Loading branch information
Showing
2 changed files
with
19 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,11 +144,11 @@ int zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, zend_dfg | |
} | ||
} else if (opline->op1_type & (IS_VAR|IS_TMP_VAR)) { | ||
var_num = EX_VAR_TO_NUM(opline->op1.var); | ||
if (opline->opcode == ZEND_VERIFY_RETURN_TYPE) { | ||
if (!DFG_ISSET(def, set_size, j, var_num)) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nikic
Author
Member
|
||
DFG_SET(use, set_size, j, var_num); | ||
} | ||
if (opline->opcode == ZEND_VERIFY_RETURN_TYPE) { | ||
DFG_SET(def, set_size, j, var_num); | ||
} else if (!DFG_ISSET(def, set_size, j, var_num)) { | ||
DFG_SET(use, set_size, j, var_num); | ||
} | ||
} | ||
if (opline->op2_type == IS_CV) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--TEST-- | ||
Incorrect liveness computation for verify-return | ||
--FILE-- | ||
<?php | ||
function test($foo): string | ||
{ | ||
switch ($foo) { | ||
default: $bar = 'x'; break; | ||
case 'z': $bar = 'y'; break; | ||
} | ||
return (string)$bar; | ||
} | ||
?> | ||
===DONE=== | ||
--EXPECT-- | ||
===DONE=== |
Would
if (!DFG_ISSET(def, set_size, j, var_num) || opline->opcode == ZEND_VERIFY_RETURN_TYPE)
? perhaps be better so only oneDFG_SET(use, set_size, j, var_num);
is needed?