diff --git a/Zend/tests/stack_limit/stack_limit_010.phpt b/Zend/tests/stack_limit/stack_limit_010.phpt index 9e37555e6decc..4f8358fb41e71 100644 --- a/Zend/tests/stack_limit/stack_limit_010.phpt +++ b/Zend/tests/stack_limit/stack_limit_010.phpt @@ -27,6 +27,7 @@ $expectedMaxSize = match(php_uname('s')) { 'true' => 16*1024*1024, // https://github.com/actions/runner-images/pull/3328 default => 8*1024*1024, }, + 'SunOS' => 10 * 1024 * 1024, 'Windows NT' => 67108864 - 4*4096, // Set by sapi/cli/config.w32 }; diff --git a/Zend/zend_call_stack.c b/Zend/zend_call_stack.c index a89e9898ee864..ad6c1932553a9 100644 --- a/Zend/zend_call_stack.c +++ b/Zend/zend_call_stack.c @@ -68,6 +68,7 @@ typedef int boolean_t; #include #include #include +#include #endif #ifdef ZEND_CHECK_STACK_LIMIT @@ -664,43 +665,17 @@ static bool zend_call_stack_get_netbsd(zend_call_stack *stack) #endif /* defined(__NetBSD__) */ #if defined(__sun) -# if defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) static bool zend_call_stack_get_solaris_pthread(zend_call_stack *stack) { - pthread_attr_t attr; - int error; - void *addr; - size_t max_size, guard_size; - - error = pthread_attr_get_np(pthread_self(), &attr); - if (error) { - return false; - } - - error = pthread_attr_getstack(&attr, &addr, &max_size); - if (error) { - return false; - } - - error = pthread_attr_getguardsize(&attr, &guard_size); - if (error) { + stack_t s; + if (thr_stksegment(&s) < 0) { return false; } - addr = (char *)addr + guard_size; - max_size -= guard_size; - - stack->base = (char *)addr + max_size; - stack->max_size = max_size; - + stack->max_size = s.ss_size; + stack->base = s.ss_sp; return true; } -# else /* defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */ -static bool zend_call_stack_get_solaris_pthread(zend_call_stack *stack) -{ - return false; -} -# endif /* defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */ static bool zend_call_stack_get_solaris_proc_maps(zend_call_stack *stack) { @@ -723,7 +698,7 @@ static bool zend_call_stack_get_solaris_proc_maps(zend_call_stack *stack) } size = (1 << 20); - snprintf(path, sizeof(path), "/proc/%d/map", pid); + snprintf(path, sizeof(path), "/proc/%d/map", (int)pid); if ((fd = open(path, O_RDONLY)) == -1) { Prelease(proc, 0);