1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/standard/tests/general_functions/gh20840.phpt
Ilija Tovilo 462fcad419 Avoid huge output in gh20840.phpt
This can trigger the memory limit in run-tests.php, which buffers the tests
output. Instead, only output "nesting level too deep" and discard the rest.

Closes GH-20946
2026-01-16 13:03:53 +01:00

48 lines
1014 B
PHP

--TEST--
GH-20840 (var_dump() crash with nested objects)
--CREDITS--
bendrissou
--SKIPIF--
<?php
if (ini_get('zend.max_allowed_stack_size') === false) {
die('skip No stack limit support');
}
if (getenv('SKIP_ASAN')) {
die('skip ASAN needs different stack limit setting due to more stack space usage');
}
?>
--INI--
zend.max_allowed_stack_size=512K
--FILE--
<?php
class Node {
public $next;
}
$firstNode = new Node();
$node = $firstNode;
for ($i = 0; $i < 50000; $i++) {
$newNode = new Node();
$node->next = $newNode;
$node = $newNode;
}
$buffer = '';
ob_start(function ($chunk) use (&$buffer) {
$buffer .= $chunk;
$buffer = preg_replace('(\s*object\(Node\)#\d+ \(\d+\) \{\s*)', '', $buffer);
$buffer = preg_replace('(\s*\["next"\]=>\s*)', '', $buffer);
$buffer = preg_replace('(\s*\}\s*)', '', $buffer);
});
var_dump($firstNode);
ob_end_flush();
echo $buffer;
while ($next = $firstNode->next) {
$firstNode->next = $next->next;
}
?>
--EXPECT--
nesting level too deep