1--TEST-- 2Stack limit 010 - Check stack size detection against known defaults 3--EXTENSIONS-- 4zend_test 5--SKIPIF-- 6<?php 7if (!function_exists('zend_test_zend_call_stack_get')) die("skip zend_test_zend_call_stack_get() is not available"); 8if (!getenv('STACK_LIMIT_DEFAULTS_CHECK')) { die('skip STACK_LIMIT_DEFAULTS_CHECK not set'); } 9?> 10--FILE-- 11<?php 12 13$stack = zend_test_zend_call_stack_get(); 14 15var_dump($stack); 16 17$expectedMaxSize = match(php_uname('s')) { 18 'Darwin' => match(php_uname('m')) { 19 'x86_64' => 8*1024*1024, 20 'arm64' => 8372224, 21 }, 22 'FreeBSD' => match(php_uname('m')) { 23 'amd64' => 512*1024*1024 - 4096, 24 'i386' => 64*1024*1024 - 4096, 25 }, 26 'Linux' => match (getenv('GITHUB_ACTIONS')) { 27 'true' => 16*1024*1024, // https://github.com/actions/runner-images/pull/3328 28 default => 8*1024*1024, 29 }, 30 'Windows NT' => 67108864 - 4*4096, // Set by sapi/cli/config.w32 31}; 32 33printf("Expected max_size: 0x%x\n", $expectedMaxSize); 34printf("Actual max_size: %s\n", $stack['max_size']); 35 36var_dump($stack['max_size'] === sprintf('0x%x', $expectedMaxSize)); 37 38?> 39--EXPECTF-- 40array(4) { 41 ["base"]=> 42 string(%d) "0x%x" 43 ["max_size"]=> 44 string(%d) "0x%x" 45 ["position"]=> 46 string(%d) "0x%x" 47 ["EG(stack_limit)"]=> 48 string(%d) "0x%x" 49} 50Expected max_size: 0x%x 51Actual max_size: 0x%x 52bool(true) 53