ref: 42af404efe19f04e58314b20f82df5277b60ff01
parent: ab350c2f29c6b38c68bb365c9919fa709490f57d
author: Wan-Teh Chang <[email protected]>
date: Fri Apr 3 10:17:30 EDT 2020
Look up __pthread_get_minstack only in glibc Android uses bionic, not glibc, as the C library. __linux__ is also defined for Android, so also test __GLIBC__ to avoid looking up __pthread_get_minstack in Android bionic. Also, include <dlfcn.h> only if HAVE_DLSYM is defined. In glibc, <dlfcn.h> includes <features.h>, which defines __GLIBC__.
--- a/src/lib.c
+++ b/src/lib.c
@@ -31,7 +31,7 @@
#include <errno.h>
#include <string.h>
-#ifdef __linux__
+#if defined(__linux__) && defined(HAVE_DLSYM)
#include <dlfcn.h>
#endif
@@ -81,7 +81,7 @@
NO_SANITIZE("cfi-icall") // CFI is broken with dlsym()
static COLD size_t get_stack_size_internal(const pthread_attr_t *const thread_attr) {
-#if defined(__linux__) && defined(HAVE_DLSYM)
+#if defined(__linux__) && defined(HAVE_DLSYM) && defined(__GLIBC__)
/* glibc has an issue where the size of the TLS is subtracted from the stack
* size instead of allocated separately. As a result the specified stack
* size may be insufficient when used in an application with large amounts