Skip to content

Commit 4c36b07

Browse files
committed
gh-159603: Call pthread_attr_init() in hardware_stack_limits()
Always call pthread_attr_init() in hardware_stack_limits(), not only on FreeBSD (if pthread_attr_get_np() is available).
1 parent 71ba39d commit 4c36b07

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎Python/ceval.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,12 @@ hardware_stack_limits(uintptr_t *base, uintptr_t *top, uintptr_t sp)
158158
size_t stack_size, guard_size;
159159
void *stack_addr;
160160
pthread_attr_t attr;
161-
#ifdef _Py_HAVE_PTHREAD_ATTR_GET_NP
161+
162162
int err = pthread_attr_init(&attr);
163+
#ifdef _Py_HAVE_PTHREAD_ATTR_GET_NP
163164
err |= pthread_attr_get_np(pthread_self(), &attr);
164165
#else
165-
int err = pthread_getattr_np(pthread_self(), &attr);
166+
err |= pthread_getattr_np(pthread_self(), &attr);
166167
#endif
167168
if (err == 0) {
168169
err = pthread_attr_getguardsize(&attr, &guard_size);
@@ -175,6 +176,7 @@ hardware_stack_limits(uintptr_t *base, uintptr_t *top, uintptr_t sp)
175176
return;
176177
}
177178
# endif
179+
178180
// Add some space for caller function then round to minimum page size
179181
// This is a guess at the top of the stack, but should be a reasonably
180182
// good guess if called from _PyThreadState_Attach when creating a thread.

0 commit comments

Comments
 (0)