Skip to content

Commit 07bf42d

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
2 parents 381d0dd + e217138 commit 07bf42d

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ PHP NEWS
1717
. Fix inverted bailout value in zend_runtime_jit() (Max Kellermann).
1818
. Fix access to uninitialized variable in accel_preload(). (nielsdos)
1919
. Fix zend_jit_find_trace() crashes. (Max Kellermann)
20+
. Added missing lock for EXIT_INVALIDATE in zend_jit_trace_exit. (Max Kellermann)
2021

2122
- PHPDBG:
2223
. Fix undefined behaviour in phpdbg_load_module_or_extension(). (nielsdos)

ext/opcache/jit/zend_jit_trace.c

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8202,22 +8202,34 @@ int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf
82028202
t = &zend_jit_traces[num];
82038203
}
82048204

8205-
SHM_UNPROTECT();
8206-
zend_jit_unprotect();
8205+
zend_shared_alloc_lock();
82078206

82088207
jit_extension = (zend_jit_op_array_trace_extension*)ZEND_FUNC_INFO(t->op_array);
8209-
if (ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags & ZEND_JIT_TRACE_START_LOOP) {
8210-
((zend_op*)(t->opline))->handler = (const void*)zend_jit_loop_trace_counter_handler;
8211-
} else if (ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags & ZEND_JIT_TRACE_START_ENTER) {
8212-
((zend_op*)(t->opline))->handler = (const void*)zend_jit_func_trace_counter_handler;
8213-
} else if (ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags & ZEND_JIT_TRACE_START_RETURN) {
8214-
((zend_op*)(t->opline))->handler = (const void*)zend_jit_ret_trace_counter_handler;
8208+
8209+
/* Checks under lock, just in case something has changed while we were waiting for the lock */
8210+
if (!(ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags & (ZEND_JIT_TRACE_JITED|ZEND_JIT_TRACE_BLACKLISTED))) {
8211+
/* skip: not JIT-ed nor blacklisted */
8212+
} else if (ZEND_JIT_TRACE_NUM >= JIT_G(max_root_traces)) {
8213+
/* skip: too many root traces */
8214+
} else {
8215+
SHM_UNPROTECT();
8216+
zend_jit_unprotect();
8217+
8218+
if (ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags & ZEND_JIT_TRACE_START_LOOP) {
8219+
((zend_op*)(t->opline))->handler = (const void*)zend_jit_loop_trace_counter_handler;
8220+
} else if (ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags & ZEND_JIT_TRACE_START_ENTER) {
8221+
((zend_op*)(t->opline))->handler = (const void*)zend_jit_func_trace_counter_handler;
8222+
} else if (ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags & ZEND_JIT_TRACE_START_RETURN) {
8223+
((zend_op*)(t->opline))->handler = (const void*)zend_jit_ret_trace_counter_handler;
8224+
}
8225+
ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags &=
8226+
ZEND_JIT_TRACE_START_LOOP|ZEND_JIT_TRACE_START_ENTER|ZEND_JIT_TRACE_START_RETURN;
8227+
8228+
zend_jit_protect();
8229+
SHM_PROTECT();
82158230
}
8216-
ZEND_OP_TRACE_INFO(t->opline, jit_extension->offset)->trace_flags &=
8217-
ZEND_JIT_TRACE_START_LOOP|ZEND_JIT_TRACE_START_ENTER|ZEND_JIT_TRACE_START_RETURN;
82188231

8219-
zend_jit_protect();
8220-
SHM_PROTECT();
8232+
zend_shared_alloc_unlock();
82218233

82228234
return 0;
82238235
}

0 commit comments

Comments
 (0)