Skip to content

Conversation

arnaud-lb
Copy link
Member

Fixes GH-19889.

zend_runtime_jit() prevents concurrent compilation with zend_shared_alloc_lock(), but this doesn't prevent blocked threads from trying to compile the function again after they acquire the lock.

In the case of GH-19889, one of the function entries is compiled with zend_jit_handler(), which fails when the op handler has been replaced by a JIT'ed handler.

This can be produced with this script:

function f(int $a, int ...$b) {
    // RECV $a
    // RECV_VARIADIC $b: second entry, compiled with zend_jit_handler()
    // RETURN $b
    return $b;
}

$f = 'f';
var_dump($f(1,2));

Fix by marking compiled functions with a new flag ZEND_FUNC_JITED, and skipping compilation of marked functions. The same fix is applied to zend_jit_hot_func().

@dktapps
Copy link
Contributor

dktapps commented Sep 26, 2025

A/B test confirmed this fixes my application's issue 👍🏻

@arnaud-lb arnaud-lb marked this pull request as ready for review September 26, 2025 15:12
@arnaud-lb arnaud-lb requested a review from dstogov as a code owner September 26, 2025 15:12
@arnaud-lb arnaud-lb closed this in 359ad80 Oct 7, 2025
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.

JIT 1211-1215 assert fail in ZTS when multiple threads are running
3 participants