From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by sourceware.org (Postfix) with ESMTPS id A9A04385702F; Thu, 22 Apr 2021 18:28:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A9A04385702F Received: by mail-oi1-x22e.google.com with SMTP id v6so18913836oiv.3; Thu, 22 Apr 2021 11:28:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GH2dZw030mGIgaTtni35luKOSSNQsc7Hts2P3ZT7Vvo=; b=p49lEkkID1BPjH1n6xkkFDll7A1bJD1zOdOaIm5eHwgEgcn00VYBAkmNXcfYPQ6U/o I+aAj5NXVRuSEHJT/GVEl6+/P0aA3Q+d6liRWA9pkkQenkGU48Ig/Ya2xn6g4cgTmqoJ vNSnBW/85XCM8K2Jc34Fa3A9mK7WcjPoXfPvk++guEMsf81KjN2/4ikIfAaNqT7RtPt0 e9mxLoRUXRUI+3dbD1yjFbParun8a6mxwKKrDdBuFYtOJl339yflqWsBP4JFkK8xUhmQ HNj4iwRTMjU7mI0nc5mHAn0iTXWi5LXn+e6yRTDAyki8i4NjMVW9ILN+UBqk6S2YQxc8 4b7A== X-Gm-Message-State: AOAM530jR++ar7RAN6wfOikXN3tpVgXfXwHqngYKm9IQtiAjlfc6CGL8 LRn3By6cPkCZRytUFcfTo6r24ielNVxo6typZYg= X-Google-Smtp-Source: ABdhPJzoshyIoJIsrnUHxaxVEpegALRoDTDsbam9c2BK8U8m3NK3AlFL5dfqAeb7tFFP/UxNGopZyw6VS/G1hx6oJIY= X-Received: by 2002:aca:b208:: with SMTP id b8mr956613oif.79.1619116110968; Thu, 22 Apr 2021 11:28:30 -0700 (PDT) MIME-Version: 1.0 References: <87tuo24kxi.fsf@oldenburg.str.redhat.com> <87czunoo5m.fsf@oldenburg.str.redhat.com> <20210422072821.GE9028@arm.com> <87o8e6k9br.fsf@oldenburg.str.redhat.com> <20210422090501.GH9028@arm.com> <20210422094808.GJ9028@arm.com> <87pmymildh.fsf@oldenburg.str.redhat.com> <20210422124455.GK9028@arm.com> <20210422142030.GL9028@arm.com> <87pmymgzuy.fsf@oldenburg.str.redhat.com> <20210422153008.GM9028@arm.com> <87bla6cifb.fsf@oldenburg.str.redhat.com> In-Reply-To: <87bla6cifb.fsf@oldenburg.str.redhat.com> From: "H.J. Lu" Date: Thu, 22 Apr 2021 11:27:54 -0700 Message-ID: Subject: Re: [PATCH v3] nptl_db: Support different libpthread/ld.so load orders (bug 27744) To: Florian Weimer Cc: Szabolcs Nagy , Pedro Alves , Florian Weimer via Libc-alpha , GDB Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3034.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Apr 2021 18:28:33 -0000 On Thu, Apr 22, 2021 at 10:55 AM Florian Weimer wrote: > > * H. J. Lu: > > > On Thu, Apr 22, 2021 at 10:16 AM Szabolcs Nagy via Gdb-patches > > 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=, abstime=0x0, private=, 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.