Skip to content

test: adapt to the PHP hard memory limit - #2741

Merged
dunglas merged 3 commits into
mainfrom
fix/php-hard-memory-limit
Oct 21, 2026
Merged

dunglas merged 3 commits into
mainfrom
fix/php-hard-memory-limit

Conversation

@dunglas

@dunglas dunglas commented Oct 21, 2026

Copy link
Copy Markdown
Member

PHP 8.2.35, 8.3.36, 8.4.27 and 8.5.12 (php/php-src@31c0ea7d7f) replace the bailout on OOM with a delayed fatal error and add a hard memory limit, twice `memory_limit` by default (`memory_hard_limit_percent`). An allocation past it prints "Hard memory limit ... exhausted" and calls `_exit(137)`.

`TestUnhealthyThreadIsRestarted` sent a 16 MiB query string with `memory_limit=8M`: `php_default_treat_data()` copies it in one allocation, which crosses the 16 MiB hard limit and kills the test binary. This is why Tests and Windows are red on main since these releases.

  • Replace it with `TestOutOfMemory_module` and `TestOutOfMemory_worker`: a 5 MiB query string (under the hard limit) and an OOM inside the script both end in the usual fatal error and the thread or worker keeps serving. Without the hard limit (detected at runtime), the test still checks that the unhealthy thread is restarted.
  • Document in the known issues that crossing the hard limit stops the whole FrankenPHP process, since all requests are served by threads of one process, unlike PHP-FPM which only loses a child.

PHP 8.2.35, 8.3.36, 8.4.27 and 8.5.12 exit the process when an allocation
exceeds twice memory_limit, and no longer fail request startup on OOM.
Stay under the hard limit and cover worker mode too.
@dunglas
dunglas merged commit 4d96acb into main Oct 21, 2026
25 checks passed
@dunglas
dunglas deleted the fix/php-hard-memory-limit branch October 21, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant