[php-src] master: Zend: compile time assert on Bucket size (#23079)

From: Date: Mon, 10 Aug 2026 08:04:27 +0000
Subject: [php-src] master: Zend: compile time assert on Bucket size (#23079)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-140569@lists.php.net to get a copy of this message
Author: Sjoerd Langkemper (Sjord) Committer: GitHub (web-flow) Pusher: arnaud-lb Date: 2026-08-10T10:04:23+02:00 Commit: https://github.com/php/php-src/commit/5206ff33ca21be3bcbe5e402fcb856978ff457df Raw diff: https://github.com/php/php-src/commit/5206ff33ca21be3bcbe5e402fcb856978ff457df.diff Zend: compile time assert on Bucket size (#23079) In zend_compile.c, flags are stored in the lower bits of the Bucket address. If Bucket is aligned to 8 bytes, the lower three bits are always zero and this gives no problems. If the Bucket is not aligned, this results in non-obvious errors because the memory address and the flags overlap. This is difficult to debug when it happens, so add this assertion to make it more obvious what is wrong. The flags are ZEND_BIND_REF, ZEND_BIND_IMPLICIT, ZEND_BIND_EXPLICIT. Related to GH-19079 Changed paths: M Zend/zend_compile.c Diff: diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index a2f126fb101d..882b1bf990bf 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5916,6 +5916,8 @@ static void zend_compile_static_var_common(zend_string *var_name, zval *value, u opline = zend_emit_op(NULL, ZEND_BIND_STATIC, NULL, NULL); opline->op1_type = IS_CV; opline->op1.var = lookup_cv(var_name); + + ZEND_STATIC_ASSERT(sizeof(Bucket) % 8 == 0, "Bucket size not compatible with storing flags in lower three bits"); opline->extended_value = (uint32_t)((char*)value - (char*)CG(active_op_array)->static_variables->arData) | mode; } /* }}} */

« previous php.cvs (#140569) next »