[php-src] Issue #24631: Delayed OOM raised during compilation is dropped when compilation fails

From: Date: Sat, 24 Oct 2026 03:40:23 +0000
Subject: [php-src] Issue #24631: Delayed OOM raised during compilation is dropped when compilation fails
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-253150@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/24631 Author: pentolope ### Description If the main script exceeds memory_limit while being compiled and compilation then fails, the memory error is never reported. The parse error is reported instead. zend_execute_script() only handles a pending delayed OOM when zend_compile_file() returns an op_array: https://github.com/php/php-src/blob/31c0ea7d7ff1d1fccb6492e52dab544011628065/Zend/zend.c#L1988-L1993 @bhaak found the same problem in sapi/fuzzer/fuzzer-sapi.c: https://github.com/php/php-src/commit/31c0ea7d7ff1d1fccb6492e52dab544011628065#r206151500. Their fix also applies here: handle the delayed OOM outside the if (op_array) block. The following code: ```sh php -n -r 'file_put_contents("oom.php", "<?php\n\$a = \x27" . str_repeat("A", 3 << 19) . "\x27;\n)\n");' php -n -d memory_limit=4M oom.php ``` Resulted in this output: ``` Parse error: Unmatched ')' in oom.php on line 3 ``` But I expected this output instead: ``` Fatal error: Allowed memory size of 4194304 bytes exhausted (tried to allocate 2097152 bytes) in oom.php on line 2 ``` Without the ) line, the memory error is reported. ### PHP Version ``` PHP 8.5.12-dev (cli) (NTS), built from 31c0ea7d7ff1d1fccb6492e52dab544011628065 ``` ### Operating System Linux x86_64

« previous php.bugs (#253150) next »