From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id nmVQInByQmBGFwAAWB0awg (envelope-from ) for ; Fri, 05 Mar 2021 13:03:28 -0500 Received: by simark.ca (Postfix, from userid 112) id 7BBFF1EF78; Fri, 5 Mar 2021 13:03:28 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 090CA1E54D for ; Fri, 5 Mar 2021 13:03:28 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 81AEA3834405; Fri, 5 Mar 2021 18:03:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 81AEA3834405 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614967407; bh=GjqiD8+2DqdfQ2/mIr+RJeYychChVAfDyzl4Qm5dUIo=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Y8pM4Y84eCSa2/bPj40fOjz1S9MW1RhwbzKytGrBCrk3NehUDk1G+cDELRjgjBJPl cKHwO05a2ZV2bVm/UnnjH9kVW+AXu4qox50t5/H1LxhV017XmUtyyC+5gR4Tspvx0D hhiyhHLirI2wmFLxlLabHOfm40LJCuYfeQlHdalE= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 62F313834405 for ; Fri, 5 Mar 2021 18:03:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 62F313834405 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-549-FXPj7oDSOA2Ti0OatDvokQ-1; Fri, 05 Mar 2021 13:03:12 -0500 X-MC-Unique: FXPj7oDSOA2Ti0OatDvokQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F0D7A8042C3; Fri, 5 Mar 2021 18:03:10 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-113-208.ams2.redhat.com [10.36.113.208]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E41DD50E2F; Fri, 5 Mar 2021 18:03:09 +0000 (UTC) To: Simon Marchi Subject: Re: [PATCH] nptl: Move stack list variables into _rtld_global References: <87a6vlthqn.fsf@oldenburg2.str.redhat.com> <0f7bf7d7-36f9-ce7f-0390-4b39eeb0fffc@polymtl.ca> <87zgzhbjy0.fsf@oldenburg.str.redhat.com> Date: Fri, 05 Mar 2021 19:03:19 +0100 In-Reply-To: (Simon Marchi's message of "Fri, 5 Mar 2021 12:58:21 -0500") Message-ID: <87mtvhbhqw.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Florian Weimer via Gdb-patches Reply-To: Florian Weimer Cc: Simon Marchi via Libc-alpha , gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" * 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