aboutsummaryrefslogtreecommitdiffstats
path: root/libc/bionic/pthread_internal.h
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2012-10-16 15:54:46 -0700
committerElliott Hughes <enh@google.com>2012-10-16 17:58:17 -0700
commit5419b9474753d25dff947c7740532f86d130c0be (patch)
tree4d746cfc20a1d3b5886f691ed1a49ddf34e2df78 /libc/bionic/pthread_internal.h
parenta9944cfe9e152ca46afb0a77300ec5a2a1a24e64 (diff)
downloadandroid_bionic-5419b9474753d25dff947c7740532f86d130c0be.tar.gz
android_bionic-5419b9474753d25dff947c7740532f86d130c0be.tar.bz2
android_bionic-5419b9474753d25dff947c7740532f86d130c0be.zip
Make dlerror(3) thread-safe.
I gave up trying to use the usual thread-local buffer idiom; calls to calloc(3) and free(3) from any of the "dl" functions -- which live in the dynamic linker -- end up resolving to the dynamic linker's stubs. I tried to work around that, but was just making things more complicated. This alternative costs us a well-known TLS slot (instead of the dynamically-allocated TLS slot we'd have used otherwise, so no difference there), plus an extra buffer inside every pthread_internal_t. Bug: 5404023 Change-Id: Ie9614edd05b6d1eeaf7bf9172792d616c6361767
Diffstat (limited to 'libc/bionic/pthread_internal.h')
-rw-r--r--libc/bionic/pthread_internal.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h
index 58a809a26..4bc81efe4 100644
--- a/libc/bionic/pthread_internal.h
+++ b/libc/bionic/pthread_internal.h
@@ -45,6 +45,13 @@ typedef struct pthread_internal_t
int internal_flags;
__pthread_cleanup_t* cleanup_stack;
void** tls; /* thread-local storage area */
+
+ /*
+ * The dynamic linker implements dlerror(3), which makes it hard for us to implement this
+ * per-thread buffer by simply using malloc(3) and free(3).
+ */
+#define __BIONIC_DLERROR_BUFFER_SIZE 512
+ char dlerror_buffer[__BIONIC_DLERROR_BUFFER_SIZE];
} pthread_internal_t;
int _init_thread(pthread_internal_t* thread, pid_t kernel_id, pthread_attr_t* attr,