[patch] initialize bootstrap_map.l_tls_modid

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[patch] initialize bootstrap_map.l_tls_modid

Rafael Espíndola
Running some tests on qemu I sometimes hit the assertion

_dl_start_final: Assertion `info->l.l_tls_modid == 0'

I initially thought that it was a bug in qemu, but investigating
further showed that  bootstrap_map.l_tls_modid was stack allocated but
not initialized.

The attached patch initializes it to 0. The bug is a bit hard to
reproduce, but it can be done by initializing l_tls_modid to another
value.

Should I add a bug report in bugzilla?

Best Regards,
Rafael

libc.patch (642 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [patch] initialize bootstrap_map.l_tls_modid

Jakub Jelinek
On Fri, Sep 29, 2006 at 07:50:21AM -0300, Rafael Esp?ndola wrote:

> Running some tests on qemu I sometimes hit the assertion
>
> _dl_start_final: Assertion `info->l.l_tls_modid == 0'
>
> I initially thought that it was a bug in qemu, but investigating
> further showed that  bootstrap_map.l_tls_modid was stack allocated but
> not initialized.
>
> The attached patch initializes it to 0. The bug is a bit hard to
> reproduce, but it can be done by initializing l_tls_modid to another
> value.

I'd prefer not to waste runtime cycles just so that something can
be asserted.  If !USE___THREAD in rtld.c (currently always), then we really
don't need it for anything in bootstrap_map (and it is already zero
initialized in GL(dl_rtld_map)).

2006-09-29  Jakub Jelinek  <[hidden email]>

        * elf/rtld.c (_dl_start_final): If not USE___THREAD, don't
        assert bootstrap_map.l_tls_modid is zero.
        (_dl_start): Initialize bootstrap_map.l_tls_modid to 0
        if USE___THREAD.

--- libc/elf/rtld.c.jj 2006-06-21 17:36:37.000000000 +0200
+++ libc/elf/rtld.c 2006-09-29 14:02:39.000000000 +0200
@@ -303,7 +303,6 @@ _dl_start_final (void *arg, struct dl_st
   GL(dl_rtld_map).l_tls_offset = info->l.l_tls_offset;
   GL(dl_rtld_map).l_tls_modid = 1;
 # else
-  assert (info->l.l_tls_modid == 0);
 #  if NO_TLS_OFFSET != 0
   GL(dl_rtld_map).l_tls_offset = NO_TLS_OFFSET;
 #  endif
@@ -389,6 +388,9 @@ _dl_start (void *arg)
        ++cnt)
     bootstrap_map.l_info[cnt] = 0;
 # endif
+# if USE___THREAD
+  bootstrap_map.l_tls_modid = 0;
+# endif
 #endif
 
   /* Figure out the run-time load address of the dynamic linker itself.  */

        Jakub