Files
Calvin Buckley 415a415381 zend_call_stack.c: AIX backend (#22906)
Uses pthread_getthrds_np (so requires pthread linked, by default on ZTS,
needs to be added for NTS). The stack size part is weird, but works in
testing.

An alternative approach is using procfs, but I didn't bother with this
due to it not working on PASE (and the pthread approach works for the
main thread too).
2026-07-31 16:26:47 -03:00

59 lines
1.6 KiB
PHP

--TEST--
Stack limit 010 - Check stack size detection against known defaults
--EXTENSIONS--
zend_test
--SKIPIF--
<?php
if (PHP_OS_FAMILY == "AIX") {
die("skip AIX adjusts top of stack (used for size) in unpredictable way");
}
if (!function_exists('zend_test_zend_call_stack_get')) die("skip zend_test_zend_call_stack_get() is not available");
if (!getenv('STACK_LIMIT_DEFAULTS_CHECK')) { die('skip STACK_LIMIT_DEFAULTS_CHECK not set'); }
?>
--FILE--
<?php
$stack = zend_test_zend_call_stack_get();
var_dump($stack);
$expectedMaxSize = match(php_uname('s')) {
'Darwin' => match(php_uname('m')) {
'x86_64' => 8*1024*1024,
'arm64' => 8372224,
},
'FreeBSD' => match(php_uname('m')) {
'amd64' => 512*1024*1024 - 4096,
'i386' => 64*1024*1024 - 4096,
},
'Linux' => match (getenv('GITHUB_ACTIONS')) {
'true' => 16*1024*1024, // https://github.com/actions/runner-images/pull/3328
default => 8*1024*1024,
},
'SunOS' => preg_match('/(omnios|illumos|smartos|oi-|openindiana|joyent)/i', php_uname('v'))
? 10 * 1024 * 1024
: 8 * 1024 * 1024,
'Windows NT' => 67108864 - 4*4096, // Set by sapi/cli/config.w32
};
printf("Expected max_size: 0x%x\n", $expectedMaxSize);
printf("Actual max_size: %s\n", $stack['max_size']);
var_dump($stack['max_size'] === sprintf('0x%x', $expectedMaxSize));
?>
--EXPECTF--
array(4) {
["base"]=>
string(%d) "0x%x"
["max_size"]=>
string(%d) "0x%x"
["position"]=>
string(%d) "0x%x"
["EG(stack_limit)"]=>
string(%d) "0x%x"
}
Expected max_size: 0x%x
Actual max_size: 0x%x
bool(true)