-
Notifications
You must be signed in to change notification settings - Fork 8k
Expand file tree
/
Copy pathgh20836_stack_limit.phpt
More file actions
38 lines (34 loc) · 1 KB
/
gh20836_stack_limit.phpt
File metadata and controls
38 lines (34 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--TEST--
GH-20836 (Stack overflow in mb_convert_variables with recursive array references, stack limit case)
--EXTENSIONS--
mbstring
--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=256K
--FILE--
<?php
function createDeepArray($depth) {
if ($depth <= 0) {
return 'deep value';
}
return ['nested' => createDeepArray($depth - 1)];
}
// Create a deeply nested array that will trigger stack limit
$deepArray = createDeepArray(15000);
mb_convert_variables('utf-8', 'utf-8', $deepArray);
echo "Done\n";
?>
--EXPECTF--
Fatal error: Uncaught Error: Maximum call stack size of %d bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? in %s:%d
Stack trace:
#0 %s(%d): mb_convert_variables('utf-8', 'utf-8', Array)
#1 {main}
thrown in %s on line %d