From 3e4497dab1b345420b422eef313553376bd10048 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 584d3b5f1b1..76f764298f9 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -516,6 +516,11 @@ native_thread_destroy_self(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