Skip to content

Commit 5fec155

Browse files
committed
Prevent trace recorder reenterancing
1 parent b4ae5a2 commit 5fec155

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

ext/opcache/jit/zend_jit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ typedef struct _zend_jit_globals {
109109

110110
zend_sym_node *symbols; /* symbols for disassembler */
111111

112+
zend_bool tracing;
113+
112114
zend_jit_trace_rec *current_trace;
113115
zend_jit_trace_stack_frame *current_frame;
114116

ext/opcache/jit/zend_jit_trace.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5038,6 +5038,11 @@ int ZEND_FASTCALL zend_jit_trace_hot_root(zend_execute_data *execute_data, const
50385038
return 0;
50395039
}
50405040

5041+
if (JIT_G(tracing)) {
5042+
++(*ZEND_OP_TRACE_INFO(opline, offset)->counter);
5043+
return 0;
5044+
}
5045+
50415046
if (JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_START) {
50425047
fprintf(stderr, "---- TRACE %d start (%s) %s() %s:%d\n",
50435048
trace_num,
@@ -5053,8 +5058,10 @@ int ZEND_FASTCALL zend_jit_trace_hot_root(zend_execute_data *execute_data, const
50535058
goto abort;
50545059
}
50555060

5061+
JIT_G(tracing) = 1;
50565062
stop = zend_jit_trace_execute(execute_data, opline, trace_buffer,
50575063
ZEND_OP_TRACE_INFO(opline, offset)->trace_flags & ZEND_JIT_TRACE_START_MASK, 0);
5064+
JIT_G(tracing) = 0;
50585065

50595066
if (UNEXPECTED(JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_BYTECODE)) {
50605067
zend_jit_dump_trace(trace_buffer, NULL);
@@ -5335,7 +5342,9 @@ int ZEND_FASTCALL zend_jit_trace_hot_side(zend_execute_data *execute_data, uint3
53355342
}
53365343
}
53375344

5345+
JIT_G(tracing) = 1;
53385346
stop = zend_jit_trace_execute(execute_data, EX(opline), trace_buffer, ZEND_JIT_TRACE_START_SIDE, is_megamorphic);
5347+
JIT_G(tracing) = 0;
53395348

53405349
if (UNEXPECTED(JIT_G(debug) & ZEND_JIT_DEBUG_TRACE_BYTECODE)) {
53415350
zend_jit_dump_trace(trace_buffer, NULL);
@@ -5468,7 +5477,7 @@ int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf
54685477
EX(opline) = opline;
54695478
}
54705479

5471-
if (EG(vm_interrupt)) {
5480+
if (EG(vm_interrupt) || JIT_G(tracing)) {
54725481
return 1;
54735482
/* Lock-free check if the side trace was already JIT-ed or blacklist-ed in another process */
54745483
} else if (t->exit_info[exit_num].flags & (ZEND_JIT_EXIT_JITED|ZEND_JIT_EXIT_BLACKLISTED)) {
@@ -5607,6 +5616,7 @@ static void zend_jit_trace_init_caches(void)
56075616

56085617
static void zend_jit_trace_reset_caches(void)
56095618
{
5619+
JIT_G(tracing) = 0;
56105620
}
56115621

56125622
static void zend_jit_trace_restart(void)

0 commit comments

Comments
 (0)