public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tudorb at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug dynamic-link/17090] New: Assertion failure (map->l_tls_modid == cnt) when dlopen()ing initial-exec TLS shared objects under certain circumstances
Date: Wed, 25 Jun 2014 20:12:00 -0000	[thread overview]
Message-ID: <bug-17090-131@http.sourceware.org/bugzilla/> (raw)

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.


             reply	other threads:[~2014-06-25 20:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-25 20:12 tudorb at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-17090-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).