Skip to content

Commit ed37ab9

Browse files
committed
Fixed codegeneration for NOT
Fixes oss-fuzz #63749
1 parent 037d6d0 commit ed37ab9

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

ext/opcache/jit/zend_jit_ir.c

+10-5
Original file line numberDiff line numberDiff line change
@@ -3864,7 +3864,8 @@ static void zend_jit_type_check_undef(zend_jit_ctx *jit,
38643864
uint32_t var,
38653865
const zend_op *opline,
38663866
bool check_exception,
3867-
bool in_cold_path)
3867+
bool in_cold_path,
3868+
bool undef_result)
38683869
{
38693870
ir_ref if_def = ir_IF(type);
38703871

@@ -3878,7 +3879,11 @@ static void zend_jit_type_check_undef(zend_jit_ctx *jit,
38783879
}
38793880
ir_CALL_1(IR_VOID, ir_CONST_FC_FUNC(zend_jit_undefined_op_helper), ir_CONST_U32(var));
38803881
if (check_exception) {
3881-
zend_jit_check_exception(jit);
3882+
if (undef_result) {
3883+
zend_jit_check_exception_undef_result(jit, opline);
3884+
} else {
3885+
zend_jit_check_exception(jit);
3886+
}
38823887
}
38833888
ir_MERGE_WITH_EMPTY_TRUE(if_def);
38843889
}
@@ -7301,7 +7306,7 @@ static int zend_jit_bool_jmpznz(zend_jit_ctx *jit, const zend_op *opline, uint32
73017306
zend_jit_type_check_undef(jit,
73027307
type,
73037308
opline->op1.var,
7304-
opline, 1, 0);
7309+
opline, 1, 0, 1);
73057310
}
73067311
if (set_bool) {
73077312
jit_set_Z_TYPE_INFO(jit, res_addr, set_bool_not ? IS_TRUE : IS_FALSE);
@@ -12201,12 +12206,12 @@ static int zend_jit_fetch_dim_read(zend_jit_ctx *jit,
1220112206
jit_SET_EX_OPLINE(jit, opline);
1220212207
if (opline->opcode != ZEND_FETCH_DIM_IS && (op1_info & MAY_BE_UNDEF)) {
1220312208
may_throw = 1;
12204-
zend_jit_type_check_undef(jit, jit_Z_TYPE(jit, op1_addr), opline->op1.var, NULL, 0, 1);
12209+
zend_jit_type_check_undef(jit, jit_Z_TYPE(jit, op1_addr), opline->op1.var, NULL, 0, 1, 0);
1220512210
}
1220612211

1220712212
if (op2_info & MAY_BE_UNDEF) {
1220812213
may_throw = 1;
12209-
zend_jit_type_check_undef(jit, jit_Z_TYPE(jit, op2_addr), opline->op2.var, NULL, 0, 1);
12214+
zend_jit_type_check_undef(jit, jit_Z_TYPE(jit, op2_addr), opline->op2.var, NULL, 0, 1, 0);
1221012215
}
1221112216
}
1221212217

ext/opcache/tests/jit/not_003.phpt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
JIT NOT: 003
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(){y;}) . !$y;
12+
?>
13+
--EXPECTF--
14+
Fatal error: Uncaught Error: Undefined constant "y" in %snot_003.php:2
15+
Stack trace:
16+
#0 %snot_003.php(2): {closure}(2, '%s', '%s', 2)
17+
#1 {main}
18+
thrown in %snot_003.php on line 2

0 commit comments

Comments
 (0)