Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix race condition in zend_runtime_jit(), zend_jit_hot_func() #19971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
arnaud-lb wants to merge 1 commit into php:PHP-8.4
base: PHP-8.4
Choose a base branch
Loading
from arnaud-lb:gh19889

Conversation

Copy link
Member

@arnaud-lb arnaud-lb commented Sep 26, 2025

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().

Copy link
Contributor

dktapps commented Sep 26, 2025

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

arnaud-lb reacted with thumbs up emoji

@arnaud-lb arnaud-lb marked this pull request as ready for review September 26, 2025 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@dstogov dstogov dstogov approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

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

AltStyle によって変換されたページ (->オリジナル) /