[php-src] master: Prevent inlining of `zend_compile_expr_inner()` to guarantee low stack usage of compilation (#23294)

Kuba Werłos via GitHub <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Kuba Werłos (kubawerlos)
Committer: GitHub (web-flow)
Pusher: arnaud-lb
Date: 2026-08-19T11:35:00+02:00

Commit: https://github.com/php/php-src/commit/dcdc8ab02caf91a4d27c95ab3cd03a9aa00191a2
Raw diff: https://github.com/php/php-src/commit/dcdc8ab02caf91a4d27c95ab3cd03a9aa00191a2.diff

Prevent inlining of `zend_compile_expr_inner()` to guarantee low stack usage of compilation (#23294)

Changed paths:
  M  Zend/zend_compile.c


Diff:

diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index f3527330a2c9..317114265c57 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -12447,7 +12447,9 @@ static void zend_compile_stmt(zend_ast *ast) /* {{{ */
 }
 /* }}} */
 
-static void zend_compile_expr_inner(znode *result, zend_ast *ast) /* {{{ */
+/* Keep this out of zend_compile_expr(): the two form a recursion cycle, so inlining merges this
+ * frame into every nesting level of an expression, tripling the stack needed to compile it. */
+static zend_never_inline void zend_compile_expr_inner(znode *result, zend_ast *ast) /* {{{ */
 {
 	/* CG(zend_lineno) = ast->lineno; */
 	CG(zend_lineno) = zend_ast_get_lineno(ast);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.