Skip to content

Commit feffcce

Browse files
committed
ext/opcache/jit/zend_jit_trace: add missing lock for EXIT_INVALIDATE
Commit 6c25413 added the flag ZEND_JIT_EXIT_INVALIDATE which resets the trace handlers in zend_jit_trace_exit(), but forgot to lock the shared memory section. This could cause another worker process who still saw the ZEND_JIT_TRACE_JITED flag to schedule ZEND_JIT_TRACE_STOP_LINK, but when it arrived at the ZEND_JIT_DEBUG_TRACE_STOP, the handler was already reverted by the first worker process and thus zend_jit_find_trace() fails. This in turn generated a bogus jump offset in the JITed code, crashing the PHP process.
1 parent da5cbca commit feffcce

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8126,6 +8126,7 @@ int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf
81268126
t = &zend_jit_traces[num];
81278127
}
81288128

8129+
zend_shared_alloc_lock();
81298130
SHM_UNPROTECT();
81308131
zend_jit_unprotect();
81318132

@@ -8142,6 +8143,7 @@ int ZEND_FASTCALL zend_jit_trace_exit(uint32_t exit_num, zend_jit_registers_buf
81428143

81438144
zend_jit_protect();
81448145
SHM_PROTECT();
8146+
zend_shared_alloc_unlock();
81458147

81468148
return 0;
81478149
}

0 commit comments

Comments
 (0)