From 84559dab096c4b0223b3c8bb6afae20e796a154c Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Sun, 9 Aug 2026 21:10:47 +0800 Subject: [PATCH] fix(include): make ZendVM unwind lifetime safe --- src/CompilerBase.php | 19 +-------------- tests/compiler/include_require/001.phpt | 28 ++++++++++++++++++---- tests/compiler/include_require/Hello.php | 2 +- tests/compiler/include_require/no-leak.ini | 1 + 4 files changed, 26 insertions(+), 24 deletions(-) create mode 100644 tests/compiler/include_require/no-leak.ini diff --git a/src/CompilerBase.php b/src/CompilerBase.php index beb3484b..8939283c 100644 --- a/src/CompilerBase.php +++ b/src/CompilerBase.php @@ -3544,26 +3544,9 @@ class CompilerBase implements PropertyAccessContext break; } - /** - * If an included PHP file encounters a fatal error during execution—for example, - * incorrect function arguments—an exception will be thrown, unwinding directly from - * the Zend VM stack through the C++ stack. In the original implementation, - * there were several "undestroyed temporary objects." When the exception propagates back, - * those objects need to be destroyed. However, by that time the environment - * is already in a corrupted/inconsistent state, and attempting to destroy them causes a crash. - */ $fileName = $this->parseIdentifier($expr->expr); - return << --EXPECT-- -ArgumentCountError Error +include ArgumentCountError +require ArgumentCountError diff --git a/tests/compiler/include_require/Hello.php b/tests/compiler/include_require/Hello.php index 91224ec5..96b684de 100644 --- a/tests/compiler/include_require/Hello.php +++ b/tests/compiler/include_require/Hello.php @@ -1,3 +1,3 @@