public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: Szabolcs Nagy <szabolcs.nagy@arm.com>,
	Pedro Alves <palves@redhat.com>,
	 Florian Weimer via Libc-alpha <libc-alpha@sourceware.org>,
	GDB <gdb-patches@sourceware.org>
Subject: Re: [PATCH v3] nptl_db: Support different libpthread/ld.so load orders (bug 27744)
Date: Thu, 22 Apr 2021 11:27:54 -0700	[thread overview]
Message-ID: <CAMe9rOp8Z837o3Pp9ByA_0SthXuAouGUEH+VtkiOcnTLE6m+xg@mail.gmail.com> (raw)
In-Reply-To: <87bla6cifb.fsf@oldenburg.str.redhat.com>

On Thu, Apr 22, 2021 at 10:55 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Thu, Apr 22, 2021 at 10:16 AM Szabolcs Nagy via Gdb-patches
> > <gdb-patches@sourceware.org> wrote:
> >>
> >> The 04/22/2021 16:25, Florian Weimer wrote:
> >> > * Szabolcs Nagy:
> >> >
> >> > > if i rerun the link command of the test exe but with -no-pie
> >> > > instead of -pie then the test passes with that binary.
> >> > >
> >> > > i suspect gdb places the breakpoint at the wrong place in pie
> >> > > for some reason. can be ubuntu tooling specific. see the
> >> > > breakpoint location (the exe base offset is missing):
> >> >
> >> > Thanks for investigating.
> >> >
> >> > > +attach 1254516
> >> > > [New LWP 1254517]
> >> > > Trying host libthread_db library: /home/szabolcs/try/build/nptl_db/libthread_db.so.1.
> >> > > td_ta_new failed: application not linked with libthread
> >> > > thread_db_load_search returning 0
> >> > > Trying host libthread_db library: /home/szabolcs/try/build/nptl_db/libthread_db.so.1.
> >> > > [Thread debugging using libthread_db enabled]
> >> > > Using host libthread_db library "/home/szabolcs/try/build/nptl_db/libthread_db.so.1".
> >> > > thread_db_load_search returning 1
> >> > > 0x0000ffff9d3d89c4 in __futex_abstimed_wait_common64 (futex_word=0xffff9d363210, expected=1254517, clockid=<optimized out>, abstime=0x0, private=<optimized out>, cancel=cancel@entry=true) at futex-internal.c:74
> >> > > 74          err = INTERNAL_SYSCALL_CANCEL (futex_time64, futex_word, op, expected,
> >> > > +break debugger_inspection_point
> >> > > Breakpoint 1 at 0x20c0: file tst-pthread-gdb-attach.c, line 123.
> >> > > +continue
> >> >
> >> > Would you please check if the issue goes away if you replace
> >> >
> >> >            "add-symbol-file %1$s/nptl/tst-pthread-gdb-attach\n"
> >> >
> >> > with
> >> >            "file %1$s/nptl/tst-pthread-gdb-attach\n"
> >> >
> >> > ?
> >> >
> >> > (I assume this happens without --enable-hardcoded-path-in-tests.)
> >>
> >> yes, it seems gdb does not work with
> >>
> >> ld.so ./exe
> >>
> >> if exe is pie. i could not get it to work wit file either.
> >
> > Just pass -no-pie to build exe.
>
> Ah right, the penny finally dropped.  I've seen this failure before
> during regular glibc debugging.  Fedora apparently has a downstream-only
> patch. 8-/
>
> This is what I came up with:
>
> nptl: Do not build nptl/tst-pthread-gdb-attach as PIE
>
> diff --git a/nptl/Makefile b/nptl/Makefile
> index a3d1ef8d66..294bb2faa4 100644
> --- a/nptl/Makefile
> +++ b/nptl/Makefile
> @@ -377,6 +377,9 @@ endif
>  CFLAGS-tst-pthread-gdb-attach-static.c := $(CFLAGS-printers-tests)
>  CPPFLAGS-tst-pthread-gdb-attach-static.c := \
>    $(CFLAGS-printers-tests) -DDO_ADD_SYMBOL_FILE=0
> +# As of version 9.2, GDB cannot attach properly to PIE programs that
> +# were launched with an explicit ld.so invocation.
> +tst-pthread-gdb-attach-no-pie = yes

LGTM.   Thanks.

>  ifeq ($(build-shared),yes)
>  tests-printers-libs := $(shared-thread-library)
>
> It's not needed for the static test even with --enable-static-pie.
>
> Thanks,
> Florian
>


-- 
H.J.

  reply	other threads:[~2021-04-22 18:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19 10:40 Florian Weimer
2021-04-21 11:47 ` Florian Weimer
2021-04-21 22:35   ` H.J. Lu
2021-04-22  9:29     ` Florian Weimer
2021-04-22  7:28   ` Szabolcs Nagy
2021-04-22  8:33     ` Florian Weimer
2021-04-22  9:05       ` Szabolcs Nagy
2021-04-22  9:48         ` Szabolcs Nagy
2021-04-22 11:55           ` Florian Weimer
2021-04-22 12:44             ` Szabolcs Nagy
2021-04-22 14:20               ` Szabolcs Nagy
2021-04-22 14:25                 ` Florian Weimer
2021-04-22 15:30                   ` Szabolcs Nagy
2021-04-22 15:39                     ` Florian Weimer
2021-04-22 17:22                     ` H.J. Lu
2021-04-22 17:56                       ` Florian Weimer
2021-04-22 18:27                         ` H.J. Lu [this message]
2021-04-22 14:34               ` H.J. Lu

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=CAMe9rOp8Z837o3Pp9ByA_0SthXuAouGUEH+VtkiOcnTLE6m+xg@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=fweimer@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=libc-alpha@sourceware.org \
    --cc=palves@redhat.com \
    --cc=szabolcs.nagy@arm.com \
    /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).