From 656ed62d0f09a27d32283dad2e42313f7e7e9118 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Mon, 4 Nov 2019 09:29:13 -0500 Subject: [PATCH] Fix error in usage of _SC_THREAD_STACK_MIN in test _SC_THREAD_STACK_MIN is intended to be used as an argument to sysconf and not by itself. This may have slipped past testing on x86 due to the round up to page size, but failed on aarch64 because aarch64 has conservative stack guard requirements to account for different page sizes (4K and 64K). Sysconfs get used correctly elsewhere in this file, so this is likely just a typo. Signed-off-by: Siddhesh Poyarekar --- src/core/lib/gprpp/thd_posix.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/lib/gprpp/thd_posix.cc b/src/core/lib/gprpp/thd_posix.cc index 2c3ae34ed44..ed08d7420be 100644 --- a/src/core/lib/gprpp/thd_posix.cc +++ b/src/core/lib/gprpp/thd_posix.cc @@ -59,8 +59,9 @@ size_t RoundUpToPageSize(size_t size) { // Returns the minimum valid stack size that can be passed to // pthread_attr_setstacksize. size_t MinValidStackSize(size_t request_size) { - if (request_size < _SC_THREAD_STACK_MIN) { - request_size = _SC_THREAD_STACK_MIN; + size_t min_stacksize = sysconf(_SC_THREAD_STACK_MIN); + if (request_size < min_stacksize) { + request_size = min_stacksize; } // On some systems, pthread_attr_setstacksize() can fail if stacksize is