public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug dynamic-link/17090] New: Assertion failure (map->l_tls_modid == cnt) when dlopen()ing initial-exec TLS shared objects under certain circumstances
@ 2014-06-25 20:12 tudorb at gmail dot com
  2014-06-25 21:59 ` [Bug dynamic-link/17090] " tudorb at gmail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: tudorb at gmail dot com @ 2014-06-25 20:12 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=17090

            Bug ID: 17090
           Summary: Assertion failure (map->l_tls_modid == cnt) when
                    dlopen()ing initial-exec TLS shared objects under
                    certain circumstances
           Product: glibc
           Version: 2.19
            Status: NEW
          Severity: normal
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: tudorb at gmail dot com

Created attachment 7658
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7658&action=edit
test case

When loading an initial-exec TLS object after the initial segment of
dl_tls_dtv_slotinfo_list has been exhausted, the next call to
_dl_allocate_tls_init (say, when creating the next thread) will fail with:

Inconsistency detected by ld.so: dl-tls.c: 422: _dl_allocate_tls_init:
Assertion `map->l_tls_modid == cnt' failed!

glibc has a few data structures regarding thread-local storage handling. A
segmented array with all loaded shared objects that need TLS
(dl_tls_dtv_slotinfo_list) and a fixed size array (dtv, part of the TCB).

However, glibc has an incorrect assertion if an initial-exec shared object has
been successfully loaded, but is assigned a slot outside of the initial segment
of dl_tls_dtv_slotinfo_list. "cnt" is the index in the current segment, whereas
map->l_tls_modid is the index in the dtv (which includes all segments).

Changing the assertion from

          assert (map->l_tls_modid == cnt);

to

          assert (map->l_tls_modid == total + cnt);

appears to fix the problem, which confirms my hypothesis, but I'm not
well-versed in rtld internals, so there might be something I'm missing here.

I'm attaching a small test program which creates a lot of shared libraries with
initial-exec, dlopen()s them, and then creates a new thread; the call to
_dl_allocate_tls_init from within pthread_create triggers the assertion.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-07-24 13:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-25 20:12 [Bug dynamic-link/17090] New: Assertion failure (map->l_tls_modid == cnt) when dlopen()ing initial-exec TLS shared objects under certain circumstances tudorb at gmail dot com
2014-06-25 21:59 ` [Bug dynamic-link/17090] " tudorb at gmail dot com
2014-06-25 22:00 ` tudorb at gmail dot com
2014-06-26  8:38 ` fweimer at redhat dot com
2014-11-18 19:13 ` aoliva at sourceware dot org
2014-11-27 22:58 ` david.abdurachmanov at gmail dot com
2015-03-17  4:23 ` cvs-commit at gcc dot gnu.org
2015-03-17  4:37 ` aoliva at sourceware dot org
2015-05-27 14:26 ` schwab@linux-m68k.org
2015-07-24 13:46 ` siddhesh at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).