[php-src] PR #19971: Fix race condition in zend_runtime_jit(), zend_jit_hot_func()
| From: | arnaud-lb | Date: | Fri, 26 Sep 2025 09:09:37 +0000 |
| Subject: | [php-src] PR #19971: Fix race condition in zend_runtime_jit(), zend_jit_hot_func() | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-33360@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/19971
Author: arnaud-lb
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:
``` php
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().