1--TEST-- 2Stack limit 011 - Stack limit exhaustion during unwinding 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=512K 11--FILE-- 12<?php 13 14var_dump(zend_test_zend_call_stack_get()); 15 16function replace2() { 17 return preg_replace_callback('#.#', function () { 18 replace2(); 19 }, 'x'); 20} 21function replace() { 22 static $once = false; 23 return preg_replace_callback('#.#', function () use (&$once) { 24 try { 25 replace(); 26 } finally { 27 if (!$once) { 28 $once = true; 29 replace2(); 30 } 31 } 32 }, 'x'); 33} 34 35try { 36 replace(); 37} catch (Error $e) { 38 echo $e->getMessage(), "\n"; 39 echo 'Previous: ', $e->getPrevious()->getMessage(), "\n"; 40} 41 42?> 43--EXPECTF-- 44array(4) { 45 ["base"]=> 46 string(%d) "0x%x" 47 ["max_size"]=> 48 string(%d) "0x%x" 49 ["position"]=> 50 string(%d) "0x%x" 51 ["EG(stack_limit)"]=> 52 string(%d) "0x%x" 53} 54Maximum call stack size of %d bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? 55Previous: Maximum call stack size of %d bytes (zend.max_allowed_stack_size - zend.reserved_stack_size) reached. Infinite recursion? 56