Skip to content

Commit b564113

Browse files
committed
Check exception after undef var notice
For simple assignments, we may not emit an exception check elsewhere, so perform it directly after the undef var notice.
1 parent 08c29a6 commit b564113

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5896,6 +5896,8 @@ static int zend_jit_simple_assign(dasm_State **Dst,
58965896
ZEND_ASSERT(Z_MODE(val_addr) == IS_MEM_ZVAL && Z_REG(val_addr) == ZREG_FP);
58975897
| mov FCARG1d, Z_OFFSET(val_addr)
58985898
| EXT_CALL zend_jit_undefined_op_helper, r0
5899+
| test r0, r0
5900+
| jz ->exception_handler_undef
58995901
if (save_r1) {
59005902
| mov FCARG1a, aword T1 // restore
59015903
}

ext/opcache/tests/jit/assign_043.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
JIT ASSIGN: Undef var notice promoted to exception
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
opcache.protect_memory=1
9+
--FILE--
10+
<?php
11+
set_error_handler(function($_, $m) {
12+
throw new Exception($m);
13+
});
14+
try {
15+
$a = $b;
16+
NOT_REACHED;
17+
} catch (Exception $e) {
18+
echo $e->getMessage(), "\n";
19+
}
20+
?>
21+
--EXPECT--
22+
Undefined variable $b

0 commit comments

Comments
 (0)