[php-src] master: JIT: Discard veneers if generation failed
| From: | ndossche | Date: | Tue, 27 Oct 2026 19:40:25 +0000 |
| Subject: | [php-src] master: JIT: Discard veneers if generation failed | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-142847@lists.php.net to get a copy of this message | ||
Author: ndossche (ndossche)
Date: 2026-10-27T20:38:48+01:00
Commit: https://github.com/php/php-src/commit/11bea59cfb27092024caea44117613c2ecd7f283
Raw diff: https://github.com/php/php-src/commit/11bea59cfb27092024caea44117613c2ecd7f283.diff
JIT: Discard veneers if generation failed
This is the final part to fix GH-24675, after e356f985f1.
Closes GH-24675.
Closes GH-24765.
Changed paths:
M NEWS
M ext/opcache/jit/zend_jit_ir.c
Diff:
diff --git a/NEWS b/NEWS
index 1bf9bfb06679..d6a2192a5ef6 100644
--- a/NEWS
+++ b/NEWS
@@ -155,6 +155,8 @@ PHP NEWS
map_ptr offset). (prateekbhujel)
. Fixed tracing JIT losing register-allocated CVs when an interrupt is
handled at the end of a loop trace. (Levi Morrison)
+ . Fixed bug GH-24675 (function with >~1.7 MB of machine code corrupts JIT
+ buffer accounting). (ndossche)
- PDO:
. Fixed invalid ATTR_ORACLE_NULLS values being accepted and truncated.
diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c
index fc38dd5647fd..93ba49fcee74 100644
--- a/ext/opcache/jit/zend_jit_ir.c
+++ b/ext/opcache/jit/zend_jit_ir.c
@@ -449,6 +449,15 @@ static void zend_jit_commit_veneers(void)
}
}
}
+
+static void zend_jit_discard_veneers(void)
+{
+ int i, count = sizeof(zend_jit_stubs) / sizeof(zend_jit_stubs[0]);
+
+ for (i = 0; i < count; i++) {
+ zend_jit_stub_handlers[count + i] = NULL;
+ }
+}
#endif
static bool zend_jit_prefer_const_addr_load(zend_jit_ctx *jit, uintptr_t addr)
@@ -2924,7 +2933,11 @@ static void *zend_jit_ir_compile(ir_ctx *ctx, size_t *size, const char *name)
#if defined(IR_TARGET_AARCH64)
if (ctx->flags2 & IR_HAS_VENEERS) {
- zend_jit_commit_veneers();
+ if (entry) {
+ zend_jit_commit_veneers();
+ } else {
+ zend_jit_discard_veneers();
+ }
}
#endif