Skip to content

Commit 5b048dd

Browse files
committed
Tracing JIT: Fixed incorrect assumption about stack slot type
Fixes oss-fuzz #46404
1 parent 9af3759 commit 5b048dd

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

ext/opcache/jit/zend_jit_internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ typedef union _zend_jit_trace_stack {
360360
(_stack)[_slot].reg = _reg; \
361361
(_stack)[_slot].flags = _flags; \
362362
} while (0)
363+
#define RESET_STACK_MEM_TYPE(_stack, _slot) do { \
364+
(_stack)[_slot].mem_type = IS_UNKNOWN; \
365+
} while (0)
363366

364367
/* trace info flags */
365368
#define ZEND_JIT_TRACE_CHECK_INTERRUPT (1<<0)

ext/opcache/jit/zend_jit_trace.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5939,6 +5939,9 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
59395939
} else {
59405940
SET_STACK_TYPE(stack, EX_VAR_TO_NUM(opline->result.var), type,
59415941
(type == IS_UNKNOWN || !ra || !ra[ssa_op->result_def]));
5942+
if (ssa->var_info[ssa_op->result_def].type & MAY_BE_INDIRECT) {
5943+
RESET_STACK_MEM_TYPE(stack, EX_VAR_TO_NUM(opline->result.var));
5944+
}
59425945
if (type != IS_UNKNOWN) {
59435946
ssa->var_info[ssa_op->result_def].type &= ~MAY_BE_GUARD;
59445947
if (opline->opcode == ZEND_FETCH_THIS
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
JIT FETCH_DIM_R: 014
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
function foo() {
11+
$s =+ $y;
12+
$tokenthiss[$i=$s][] = $y = $y;
13+
$tokenthiss[$i][$i] + $y;
14+
}
15+
@foo();
16+
?>
17+
DONE
18+
--EXPECT--
19+
DONE

0 commit comments

Comments
 (0)