1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

zend_call_stack sort of GH-13358 follow-up. (#13368)

for threaded context, it solely uses a new api only available on
illumos.
Here using a common older api to get the stack info for the current
thread.
while at it, completing stack_limit_010 test for these platforms.
This commit is contained in:
David CARLIER
2024-02-16 14:01:03 +00:00
committed by GitHub
parent b5c3cbf94b
commit eaaffae555
2 changed files with 7 additions and 31 deletions

View File

@@ -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
};

View File

@@ -68,6 +68,7 @@ typedef int boolean_t;
#include <sys/lwp.h>
#include <sys/procfs.h>
#include <libproc.h>
#include <thread.h>
#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) {
stack_t s;
if (thr_stksegment(&s) < 0) {
return false;
}
error = pthread_attr_getstack(&attr, &addr, &max_size);
if (error) {
return false;
}
error = pthread_attr_getguardsize(&attr, &guard_size);
if (error) {
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);