From: Florian Weimer via Gdb-patches <gdb-patches@sourceware.org>
To: Simon Marchi <simon.marchi@polymtl.ca>
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, 05 Mar 2021 19:03:19 +0100 [thread overview]
Message-ID: <87mtvhbhqw.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <ef847f64-1f77-4b82-3254-d64d55f5c693@polymtl.ca> (Simon Marchi's message of "Fri, 5 Mar 2021 12:58:21 -0500")
* Simon Marchi:
> On 2021-03-05 12:15 p.m., Florian Weimer wrote:> * Simon Marchi via Libc-alpha:
>>
>>> On 2020-11-13 10:10 a.m., Florian Weimer wrote:
>>>> Now __thread_gscope_wait (the function behind THREAD_GSCOPE_WAIT,
>>>> formerly __wait_lookup_done) can be implemented directly in ld.so,
>>>> eliminating the unprotected GL (dl_wait_lookup_done) function
>>>> pointer.
>>>
>>> Hi Florian,
>>>
>>> Presumably starting with this commit (I don't really know how to build a
>>> glibc and test against it), GDB fails to attach to a threaded process
>>> because libthread_db fails to initialize. See:
>>>
>>> https://sourceware.org/bugzilla/show_bug.cgi?id=27526
>>>
>>> The difference in behavior as seen from GDB is that libthread_db now
>>> asks to look up a symbol "_dl_stack_user" in module NULL. GDB can't
>>> find this symbol, which fails the initialization.
>>>
>>> Can you shed some light on this? Is this request expected, and where is
>>> GDB expected to find this symbol?
>>
>> It is not expected. This is the fallback path if _rtld_global cannot be
>> located. The actual failure is that __td_ta_rtld_global does not
>> succeed.
>
> [adding gdb-patches]
>
> Ok, thanks for that tip. Indeed I see that GDB returns PS_NOSYM for
> _rtld_global. If I now log what GDB returns:
>
> LOOKUP nptl_version in libpthread.so.0
> Found 0x7fdb02713037
> LOOKUP _rtld_global in ld-linux-x86-64.so.2
> Not found
> LOOKUP _dl_stack_user in (null)
> Not found
>
> So this lookup of _rtld_global is new too. And I think I see the
> problem, it looks like an ordering issue: libthread_db is loaded when
> GDB notices the program has libpthread loaded in it. When attaching,
> GDB walks the shared library list. In that list, libpthread comes
> before ld-linux. So at the time we try to load libthread_db, GDB hasn't
> yet noticed that the program has ld-linux loaded in it, hasn't ingested
> its symbols, so doesn't find _rtld_global.
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?
> 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.
Thanks,
Florian
next prev parent reply other threads:[~2021-03-05 18:03 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 [this message]
2021-03-05 18:45 ` Simon Marchi via Gdb-patches
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=87mtvhbhqw.fsf@oldenburg.str.redhat.com \
--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