Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: Simon Marchi via Libc-alpha <libc-alpha@sourceware.org>,
	gdb-patches@sourceware.org
Subject: Re: [PATCH] nptl: Move stack list variables into _rtld_global
Date: Fri, 5 Mar 2021 13:45:19 -0500	[thread overview]
Message-ID: <b2f1cf88-b4c4-87ab-f311-214c83dfab9a@polymtl.ca> (raw)
In-Reply-To: <87mtvhbhqw.fsf@oldenburg.str.redhat.com>



On 2021-03-05 1:03 p.m., Florian Weimer wrote:
> Oh, that reads like a plausible explanation.  And I assume the
> non-attaching case, where GDB starts the process, is very different, and
> this ordering issue does not appear?

Indeed, in that case ld-linux-x86-64.so.2 is loaded before
libpthread.so.0 (ld-linux is necessarily loaded before the others, I
guess, since it's the one loading the others).  So the symbol is found:

    LOOKUP _rtld_global in ld-linux-x86-64.so.2
    Found 0x7ffff7ffd000

>> If we have to deal with this, I guess that GDB should now do things in a
>> different order: go through the whole library list and load their
>> symbols.  And then if one of those libraries were libpthread, try to
>> initialize libthread_db.
> 
> Initialization of libthread_db should be unconditional.  Programs use
> TLS data without linking against libpthread.  And glibc 2.34 might not
> have a separate libpthread at all.

Ok, currently GDB attempts to load libthread_db when noticing the main
objfile / program (I guess it is needed if the program is statically
linked to libpthread?) or when seeing a library named libpthread*.

I'm not sure how to fix this, other than making GDB attempt to load
libthread_db on every new shared library it notices, since that new
shared library may "finally" make it work.  The current code
specifically exists to avoid trying to load libthread_db for every new
shared library we notice, since that was considered wasteful.  Here's
the original thread about it:

  https://sourceware.org/pipermail/gdb-patches/2011-October/085781.html
  https://pi.simark.ca/gdb-patches/20111005182705.D744E2461D1@ruffy.mtv.corp.google.com/

About the hypothetical scenario for glibc 2.34: do you mean that the
pthread infrastructure will directly be in libc.so?  If so, our current
strategy of attempting to load libthread_db only for the main program
or a libpthread* library will indeed not work.  And I suppose that will
also require trying to load libthread_db on every new shared lib...

Simon

  reply	other threads:[~2021-03-05 18:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87a6vlthqn.fsf@oldenburg2.str.redhat.com>
     [not found] ` <0f7bf7d7-36f9-ce7f-0390-4b39eeb0fffc@polymtl.ca>
     [not found]   ` <87zgzhbjy0.fsf@oldenburg.str.redhat.com>
2021-03-05 17:58     ` Simon Marchi via Gdb-patches
2021-03-05 18:03       ` Florian Weimer via Gdb-patches
2021-03-05 18:45         ` Simon Marchi via Gdb-patches [this message]
2021-03-05 19:00           ` Florian Weimer via Gdb-patches
2021-03-29  8:26             ` Florian Weimer
2021-03-29 14:29               ` Simon Marchi via Gdb-patches

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=b2f1cf88-b4c4-87ab-f311-214c83dfab9a@polymtl.ca \
    --to=gdb-patches@sourceware.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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