It seems that at least on x86_64 we can get static TLS entries
for dlopen():ed libraries, and thus we might end up freeing them
on dlclose. This removes the invalid assertation, and changes
the code to not crash with "invalid free" when this happens.

Signed-off-by: Timo Teräs <timo.te...@iki.fi>
---
 ldso/libdl/libdl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 8bc3071..af632dd 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -951,8 +951,8 @@ static int do_dlclose(void *vhandle, int need_fini)
 
                                        dtv_t *dtv = THREAD_DTV ();
 
-                                       
_dl_assert(!(dtv[tls_lmap->l_tls_modid].pointer.is_static));
-                                       if 
(dtv[tls_lmap->l_tls_modid].pointer.val != TLS_DTV_UNALLOCATED) {
+                                       if 
(!(dtv[tls_lmap->l_tls_modid].pointer.is_static) &&
+                                           
dtv[tls_lmap->l_tls_modid].pointer.val != TLS_DTV_UNALLOCATED) {
                                                /* Note that free is called for 
NULL is well.  We
                                                deallocate even if it is this 
dtv entry we are
                                                supposed to load.  The reason 
is that we call
-- 
1.8.0

_______________________________________________
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to