Skip to content

Commit 6602dde

Browse files
authored
zend call stack fix freebsd code path. (php#11766)
The typo in HAVE_PTHREAD_ATTR_GET_STACK (might be due to pthread_attr_get_np being different from Linux's pthread_getattr_np) led to this code path never get called on FreeBSD.
1 parent 9911ab7 commit 6602dde

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Zend/zend_call_stack.c

+6-7
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static bool zend_call_stack_is_main_thread(void) {
104104
# endif
105105
}
106106

107-
# ifdef HAVE_PTHREAD_GETATTR_NP
107+
# if defined(HAVE_PTHREAD_GETATTR_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK)
108108
static bool zend_call_stack_get_linux_pthread(zend_call_stack *stack)
109109
{
110110
pthread_attr_t attr;
@@ -145,12 +145,12 @@ static bool zend_call_stack_get_linux_pthread(zend_call_stack *stack)
145145

146146
return true;
147147
}
148-
# else /* HAVE_PTHREAD_GETATTR_NP */
148+
# else /* defined(HAVE_PTHREAD_GETATTR_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */
149149
static bool zend_call_stack_get_linux_pthread(zend_call_stack *stack)
150150
{
151151
return false;
152152
}
153-
# endif /* HAVE_PTHREAD_GETATTR_NP */
153+
# endif /* defined(HAVE_PTHREAD_GETATTR_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */
154154

155155
static bool zend_call_stack_get_linux_proc_maps(zend_call_stack *stack)
156156
{
@@ -251,14 +251,13 @@ static bool zend_call_stack_is_main_thread(void)
251251
return is_main == -1 || is_main == 1;
252252
}
253253

254-
# if defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GET_STACK)
254+
# if defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK)
255255
static bool zend_call_stack_get_freebsd_pthread(zend_call_stack *stack)
256256
{
257257
pthread_attr_t attr;
258258
int error;
259259
void *addr;
260260
size_t max_size;
261-
size_t guard_size;
262261

263262
/* pthread will return bogus values for the main thread */
264263
ZEND_ASSERT(!zend_call_stack_is_main_thread());
@@ -285,12 +284,12 @@ static bool zend_call_stack_get_freebsd_pthread(zend_call_stack *stack)
285284
pthread_attr_destroy(&attr);
286285
return false;
287286
}
288-
# else /* defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GET_STACK) */
287+
# else /* defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */
289288
static bool zend_call_stack_get_freebsd_pthread(zend_call_stack *stack)
290289
{
291290
return false;
292291
}
293-
# endif /* defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GET_STACK) */
292+
# endif /* defined(HAVE_PTHREAD_ATTR_GET_NP) && defined(HAVE_PTHREAD_ATTR_GETSTACK) */
294293

295294
static bool zend_call_stack_get_freebsd_sysctl(zend_call_stack *stack)
296295
{

0 commit comments

Comments
 (0)