Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Delayed OOM raised during compilation is dropped when compilation fails

Aberta
#24,631 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@srayuth089 já está trabalhando nisso.

Desde 25/10/2026.

  • #24694 de @srayuth089 — aberto

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
68/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
c, php
Domínio
backend, compilers

Direção de pesquisa

Start in Zend/zend.c around the zend_execute_script() logic linked in the issue, then compare how delayed OOM is handled in sapi/fuzzer/fuzzer-sapi.c. Reproduce with the provided php -n commands and check the result when compilation fails. Done means the memory limit error is reported instead of the parse error in that case, while the no-) case still reports the memory error.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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:

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

Linguagem predominante
C
Estrelas
40.7k
Forks
8.3k
Merge médio
2d 20h
PRs com merge (30d)
147

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de php/php-src

Todas as issues de php/php-src

Issues semelhantes

Mais issues de C

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.