1--TEST--
2Stack limit 008 - Exception handling
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
16function replace() {
17    return preg_replace_callback('#.#', function () {
18        try {
19            return replace();
20        } catch (Error $e) {
21            echo "Will throw:\n";
22            try {
23                return replace2();
24            } catch (Error $e) {
25                echo $e->getMessage();
26            }
27        }
28    }, 'x');
29}
30
31function replace2() {
32    return preg_replace_callback('#.#', function () {
33        try {
34            return '';
35        } finally {
36            // We should not enter the finally block if we haven't executed at
37            // least one op in the try block
38            echo "Finally block: This should not execute\n";
39        }
40    }, 'x');
41}
42
43replace();
44
45?>
46--EXPECTF--
47array(4) {
48  ["base"]=>
49  string(%d) "0x%x"
50  ["max_size"]=>
51  string(%d) "0x%x"
52  ["position"]=>
53  string(%d) "0x%x"
54  ["EG(stack_limit)"]=>
55  string(%d) "0x%x"
56}
57Will throw:
58Maximum call stack size of %d bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion?
59