https://github.com/ruby/ruby/pull/10633 From 605f55ebd7e94d56c3ef86635b413f30cfc33b46 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 25 Apr 2024 21:00:37 +0900 Subject: [PATCH] [Bug #20452] Take main thread address/size with rlimit if musl libc Musl libc defines `pthread_getattr_np` but it can not get the correct value of the main thread. --- thread_pthread.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/thread_pthread.c b/thread_pthread.c index 493350b52055af..9199edc3543e59 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1791,6 +1791,11 @@ native_thread_destroy(struct rb_native_thread *nt) #if defined HAVE_PTHREAD_GETATTR_NP || defined HAVE_PTHREAD_ATTR_GET_NP #define STACKADDR_AVAILABLE 1 +# if defined(__linux__) && !defined __GLIBC__ + /* Musl libc defines `pthread_getattr_np` but it can not get the + * correct value of the main thread. */ +# define MAINSTACKADDR_AVAILABLE 0 +# endif #elif defined HAVE_PTHREAD_GET_STACKADDR_NP && defined HAVE_PTHREAD_GET_STACKSIZE_NP #define STACKADDR_AVAILABLE 1 #undef MAINSTACKADDR_AVAILABLE