1--TEST--
2Stack limit 003 - Stack limit checks with fixed max_allowed_stack_size
3--SKIPIF--
4<?php
5if (!function_exists('zend_test_zend_call_stack_get')) die("skip zend_test_zend_call_stack_get() is not available");
6?>
7--EXTENSIONS--
8zend_test
9--INI--
10zend.max_allowed_stack_size=256K
11--FILE--
12<?php
13
14var_dump(zend_test_zend_call_stack_get());
15
16class Test1 {
17    public function __destruct() {
18        new Test1;
19    }
20}
21
22class Test2 {
23    public function __clone() {
24        clone $this;
25    }
26}
27
28function replace() {
29    return preg_replace_callback('#.#', function () {
30        return replace();
31    }, 'x');
32}
33
34try {
35    new Test1;
36} catch (Error $e) {
37    echo $e->getMessage(), "\n";
38}
39
40try {
41    clone new Test2;
42} catch (Error $e) {
43    echo $e->getMessage(), "\n";
44}
45
46try {
47    replace();
48} catch (Error $e) {
49    echo $e->getMessage(), "\n";
50}
51
52?>
53--EXPECTF--
54array(4) {
55  ["base"]=>
56  string(%d) "0x%x"
57  ["max_size"]=>
58  string(%d) "0x%x"
59  ["position"]=>
60  string(%d) "0x%x"
61  ["EG(stack_limit)"]=>
62  string(%d) "0x%x"
63}
64Maximum call stack size of %d bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion?
65Maximum call stack size of %d bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion?
66Maximum call stack size of %d bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion?
67