Skip to content

Fix opcache.jit_max_root_traces accepting values outside of its valid range - #25734

Open
marc-mabe wants to merge 1 commit into
php:PHP-8.4from
marc-mabe:fix/opcache-jit-max-root-traces
Open

marc-mabe wants to merge 1 commit into
php:PHP-8.4from
marc-mabe:fix/opcache-jit-max-root-traces

Conversation

@marc-mabe

Copy link
Copy Markdown
Contributor

opcache.jit_max_root_traces was taken as is to size the root traces buffer in shared memory. A value of 0 allocated no buffer at all, so the trace counters kept in its first element overlapped the next shared memory allocation. A negative value or one as large as 2**62 on 64-bit wrapped the buffer size around, failing the allocation or leaving a buffer far too small for the traces, which crashed once they got compiled.

Reject values outside of 1 to the smaller of UINT32_MAX, as trace ids are uint32_t, and the number of root traces whose buffer size fits size_t. Like the other JIT settings, an invalid value emits a warning naming the range and keeps the default. A failure to allocate the buffer now also tells its size and which settings to change.

… range

opcache.jit_max_root_traces was taken as is to size the root traces
buffer in shared memory. A value of 0 allocated no buffer at all, so the
trace counters kept in its first element overlapped the next shared
memory allocation. A negative value or one as large as 2**62 on 64-bit
wrapped the buffer size around, failing the allocation or leaving a
buffer far too small for the traces, which crashed once they got
compiled.

Reject values outside of 1 to the smaller of UINT32_MAX, as trace ids
are uint32_t, and the number of root traces whose buffer size fits
size_t. Like the other JIT settings, an invalid value emits a warning
naming the range and keeps the default. A failure to allocate the buffer
now also tells its size and which settings to change.
@marc-mabe
marc-mabe requested a review from dstogov as a code owner November 25, 2026 09:04
@marc-mabe
marc-mabe force-pushed the fix/opcache-jit-max-root-traces branch from 1a3705b to 143cd03 Compare November 25, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant