Skip to content

Commit a054542

Browse files
committed
zend_call_stack sort of GH-13358 follow-up.
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.
1 parent 5e7783e commit a054542

File tree

2 files changed

+6
-30
lines changed

2 files changed

+6
-30
lines changed

Zend/tests/stack_limit/stack_limit_010.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ $expectedMaxSize = match(php_uname('s')) {
2727
'true' => 16*1024*1024, // https://github.com/actions/runner-images/pull/3328
2828
default => 8*1024*1024,
2929
},
30+
'SunOS' => 10 * 1024 * 1024,
3031
'Windows NT' => 67108864 - 4*4096, // Set by sapi/cli/config.w32
3132
};
3233

Zend/zend_call_stack.c

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ typedef int boolean_t;
6868
#include <sys/lwp.h>
6969
#include <sys/procfs.h>
7070
#include <libproc.h>
71+
#include <thread.h>
7172
#endif
7273

7374
#ifdef ZEND_CHECK_STACK_LIMIT
@@ -664,43 +665,17 @@ static bool zend_call_stack_get_netbsd(zend_call_stack *stack)
664665
#endif /* defined(__NetBSD__) */
665666

666667
#if defined(__sun)
667-
# if defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK)
668668
static bool zend_call_stack_get_solaris_pthread(zend_call_stack *stack)
669669
{
670-
pthread_attr_t attr;
671-
int error;
672-
void *addr;
673-
size_t max_size, guard_size;
674-
675-
error = pthread_attr_get_np(pthread_self(), &attr);
676-
if (error) {
677-
return false;
678-
}
679-
680-
error = pthread_attr_getstack(&attr, &addr, &max_size);
681-
if (error) {
682-
return false;
683-
}
684-
685-
error = pthread_attr_getguardsize(&attr, &guard_size);
686-
if (error) {
670+
stack_t s;
671+
if (thr_stksegment(&s) < 0) {
687672
return false;
688673
}
689674

690-
addr = (char *)addr + guard_size;
691-
max_size -= guard_size;
692-
693-
stack->base = (char *)addr + max_size;
694-
stack->max_size = max_size;
695-
675+
stack->max_size = s.ss_size;
676+
stack->base = (char *)s.ss_sp - stack->max_size;
696677
return true;
697678
}
698-
# else /* defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */
699-
static bool zend_call_stack_get_solaris_pthread(zend_call_stack *stack)
700-
{
701-
return false;
702-
}
703-
# endif /* defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */
704679

705680
static bool zend_call_stack_get_solaris_proc_maps(zend_call_stack *stack)
706681
{

0 commit comments

Comments
 (0)