Skip to content

Commit

Permalink
Check exception after undef var notice
Browse files Browse the repository at this point in the history
For simple assignments, we may not emit an exception check elsewhere,
so perform it directly after the undef var notice.
  • Loading branch information
nikic committed Oct 7, 2021
1 parent 08c29a6 commit b564113
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -5896,6 +5896,8 @@ static int zend_jit_simple_assign(dasm_State **Dst,
ZEND_ASSERT(Z_MODE(val_addr) == IS_MEM_ZVAL && Z_REG(val_addr) == ZREG_FP);
| mov FCARG1d, Z_OFFSET(val_addr)
| EXT_CALL zend_jit_undefined_op_helper, r0
| test r0, r0
| jz ->exception_handler_undef
if (save_r1) {
| mov FCARG1a, aword T1 // restore
}
Expand Down
22 changes: 22 additions & 0 deletions ext/opcache/tests/jit/assign_043.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
JIT ASSIGN: Undef var notice promoted to exception
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=1M
opcache.protect_memory=1
--FILE--
<?php
set_error_handler(function($_, $m) {
throw new Exception($m);
});
try {
$a = $b;
NOT_REACHED;
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Undefined variable $b

0 comments on commit b564113

Please sign in to comment.