From 3a4ea6cb9181de8386bbee6f0f5d76d6ca58866e Mon Sep 17 00:00:00 2001 From: Peter van Dommelen Date: Sun, 30 May 2021 19:21:38 +0200 Subject: [PATCH] Don't automatically adjust memory_limit to 2M As PHP has a minimum memory usage of 2M (size of allocator chunk), setting a limit below that value is not meaningful and will be automatically rounded up to the chunk size. Rather than doing this silently, show the newly introduced error message. The memory limit had to be increased to 2M for a number of tests. tests/lang/bug45392 has been marked as XFAIL. This old bugfix is not working as intended. The memory limit in main's `PG(memory_limit)` differs from the one in zend_alloc. In zend_alloc the `AG(mm_heap)->limit` is defined as `max(passed_value, ZEND_MM_CHUNK_SIZE)`. The check made in an unclean shutdown will never be true unless the memory limit is lower than ZEND_MM_CHUNK_SIZE, which happened to be the case in the test. https://bugs.php.net/bug.php?id=45392 https://github.com/php/php-src/commit/fcc0fdd125fdb9e1713f91d027fe07d680a0cf36 --- Zend/tests/fibers/out-of-memory-in-fiber.phpt | 2 +- Zend/tests/fibers/out-of-memory-in-nested-fiber.phpt | 2 +- Zend/tests/fibers/out-of-memory-in-recursive-fiber.phpt | 2 +- Zend/zend_alloc.c | 3 --- ext/standard/tests/streams/bug78902.phpt | 4 ++-- tests/lang/bug45392.phpt | 4 +++- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Zend/tests/fibers/out-of-memory-in-fiber.phpt b/Zend/tests/fibers/out-of-memory-in-fiber.phpt index 8c8d0475ecc..4d31aa6f76a 100644 --- a/Zend/tests/fibers/out-of-memory-in-fiber.phpt +++ b/Zend/tests/fibers/out-of-memory-in-fiber.phpt @@ -1,7 +1,7 @@ --TEST-- Out of Memory in a fiber --INI-- -memory_limit=10K +memory_limit=2M --SKIPIF-- real_size)) { return FAILURE; } diff --git a/ext/standard/tests/streams/bug78902.phpt b/ext/standard/tests/streams/bug78902.phpt index 1216c89bc27..c3ea8a52a16 100644 --- a/ext/standard/tests/streams/bug78902.phpt +++ b/ext/standard/tests/streams/bug78902.phpt @@ -1,14 +1,14 @@ --TEST-- Bug #78902: Memory leak when using stream_filter_append --INI-- -memory_limit=512k +memory_limit=2M --FILE-- 0) { fputs($fp, str_pad('', min($chunk,$size))); diff --git a/tests/lang/bug45392.phpt b/tests/lang/bug45392.phpt index a9bdd40af2b..5940f7bc398 100644 --- a/tests/lang/bug45392.phpt +++ b/tests/lang/bug45392.phpt @@ -2,6 +2,8 @@ Bug #45392 (ob_start()/ob_end_clean() and memory_limit) --INI-- display_errors=stderr +--XFAIL-- +The issue has not yet been resolved. --SKIPIF--