xref: /PHP-8.2/Zend/tests/gh11189_1.phpt (revision 05bd1423)
1--TEST--
2GH-11189: Exceeding memory limit in zend_hash_do_resize leaves the array in an invalid state (not packed array)
3--SKIPIF--
4<?php
5if (getenv("USE_ZEND_ALLOC") === "0") die("skip ZMM is disabled");
6?>
7--INI--
8memory_limit=2M
9--FILE--
10<?php
11
12ob_start(function() {
13    global $a;
14    for ($i = count($a); $i > 0; --$i) {
15        $a[] = 2;
16    }
17    fwrite(STDOUT, "Success");
18});
19
20$a = ["not packed" => 1];
21// trigger OOM in a resize operation
22while (1) {
23    $a[] = 1;
24}
25
26?>
27--EXPECTF--
28Success
29Fatal error: Allowed memory size of %s bytes exhausted%s(tried to allocate %s bytes) in %s on line %d
30