dlclose segfaults on x86_64

Natanael Copa natanael.copa at gmail.com
Thu Nov 1 15:26:57 UTC 2012


On Fri, Oct 5, 2012 at 1:46 PM, Natanael Copa <natanael.copa at gmail.com> wrote:
> building vlc will end up with a segfaulting ./vlc-cache-gen on x86_64.
...
> Core was generated by
> `/home/ncopa/aports/main/vlc/src/vlc-2.0.3/bin/.libs/lt-vlc-cache-gen
> ../modules'.
> Program terminated with signal 11, Segmentation fault.
> #0  0x00007f9e5fc53e30 in free (mem=0x7f9e6056a668)
>     at libc/stdlib/malloc-standard/free.c:324
> 324             p->fd = *fb;
> (gdb) bt
> #0  0x00007f9e5fc53e30 in free (mem=0x7f9e6056a668)
>     at libc/stdlib/malloc-standard/free.c:324
> #1  0x00007f9e5f0843d6 in do_dlclose (vhandle=0x7f9e60ca7be0, need_fini=1)
>     at ldso/libdl/libdl.c:960
> #2  0x00007f9e5f084a47 in dlclose (vhandle=0x7f9e60ca7be0)
>     at ldso/libdl/libdl.c:1063
> #3  0x00007f9e5ff06e1c in module_Unload (handle=<optimized out>)
>     at posix/plugin.c:89
...

Does not seem like anybody really cares, but for the record, Timo
Teräs solved it with:
--- ./ldso/libdl/libdl.c.orig
+++ ./ldso/libdl/libdl.c
@@ -951,8 +951,8 @@

                                        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


Downloadable patch is available here:
http://git.alpinelinux.org/cgit/aports/plain/main/libc0.9.32/uclibc-dlclose-fix.patch

I have a relatively small testcase application that can reproduce it
(using vlc's plugins)

-- 
Natanael Copa


More information about the uClibc mailing list