From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-4.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 580A91F4B4 for ; Fri, 16 Apr 2021 16:53:19 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 622333987C30; Fri, 16 Apr 2021 16:53:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 622333987C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1618591997; bh=+vBKWEHgMsB60pg3BpAXlwQEUac1a1KCeh+ige2/Q3A=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Qssl9ktHWvCN2lSI7bSSHiOc5DtjJkHzcNZqmAOCOUMi1YqqnvH6/YzeDTgS+6n6Z mCBOu4nczN0QhfUamEhqkZIFo5r0JPVg05o9UCwa0nnYDKK3GW7I9puf+ZPnT6mDjU f97Zmgmo9SQCjGFq9StY6Lf+u5UazHLZ6poBMFdQ= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 88CCC38930CC; Fri, 16 Apr 2021 16:53:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 88CCC38930CC Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 13GGr5Ja008998 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Apr 2021 12:53:10 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 13GGr5Ja008998 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 7E0611E01F; Fri, 16 Apr 2021 12:53:05 -0400 (EDT) Subject: Re: [PATCH glibc] nptl_db: different libpthread/ld.so load orders (bug 27744) To: Pedro Alves , Florian Weimer References: <87sg3qnrz3.fsf@oldenburg.str.redhat.com> <73b32cc6-e201-8bac-e442-e3dddcc01e0d@polymtl.ca> <625ec5fe-bd09-860a-f617-745042b94011@redhat.com> <87fszqnqi3.fsf@oldenburg.str.redhat.com> <87blaenprw.fsf@oldenburg.str.redhat.com> Message-ID: <83364527-b4aa-b7cc-928b-10d20c4338a3@polymtl.ca> Date: Fri, 16 Apr 2021 12:53:05 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 16 Apr 2021 16:53:05 +0000 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: , From: Simon Marchi via Libc-alpha Reply-To: Simon Marchi Cc: libc-alpha@sourceware.org, Kevin Buettner , gdb-patches@sourceware.org Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" On 2021-04-16 12:47 p.m., Pedro Alves wrote:> On 16/04/21 17:43, Florian Weimer wrote: >> * Pedro Alves: >> >>> On 16/04/21 17:28, Florian Weimer wrote: >>>> * Pedro Alves: >>>> >>>>> IIRC, the order which libraries are loaded by GDB hasn't changed. The >>>>> issue is that until recently (before glibc 1daccf403b1b), the stacks >>>>> lists lived in libpthread (stack_used/__stack_user), so the fact that >>>>> GDB loaded libthread_db.so before ld.so's symbols were loaded didn't >>>>> make a difference. Now they were moved to ld.so, so libthread_db.so >>>>> can't find them until GDB reads the ld.so symbols. Is this assessment >>>>> correct? >>>> >>>> Yes, I believe this is what happens. >>>> >>> >>> OK, I believe what is confusing in your commit log was the reference to >>> two different kinds of "loaded": >>> >>> "libthread_db is loaded once GDB encounters libpthread, and at this >>> point, ld.so may not have been loaded yet. " >>> >>> The first loaded is about GDB dlopening libthread_db.so. The second loaded >>> refers to reading symbols -- ld.so has been loaded by the inferior already >>> at that point. >>> >>> It would be clearer as: >>> >>> "libthread_db is loaded once GDB encounters libpthread, and at this >>> point, ld.so's symbols may not have been read by GDB yet. " >> >> I'm going to go with: >> >> “ >> libthread_db is loaded once GDB encounters libpthread, and at this >> point, ld.so may not have been processed by GDB yet. >> ” > > Sounds good. > >> >>> If I understood that correctly, then the following sentence is also a >>> bit confusing: >>> >>> "As a result, _rtld_global cannot be accessed by regular means from >>> libthread_db." >>> >>> Because that sounds to me like you were perhaps talking about some >>> magic means to reference globals, some magic relocations, or some >>> other magic voodoo only understood by glibc experts. >> >> We use the magic that GDB provides to us (ps_pglobal_lookup, I think). >> I thought that this was understood by GDB experts only. 8-) > > LOL > > I skimmed the patch, and FWIW, it LGTM. Just spotted a couple typos: > >> +/* This test runs GDB against a forked copy of itself, to check >> + whether libthreaddb can be loaded, and that access to thread-local > > libthreaddb -> libthread_db > >> +/* This function implements the subprocess un der test. It creates a > > "un der" -> "under" > > Thanks, > Pedro Alves > Do we need / want to fix GDB if this goes in glibc then? I have an updated version of my patch here [1] sitting here, that makes it work with GDBserver as well, with the "broken" glibc 2.33. I'm wondering if I should post it or not. Even without this bug, my patch can be beneficial from an efficiency point of view, since it delays sending a qSymbol to the remote side until all shared libraries are known. But then it would be a completely different rationale, I would have to word the commit message in terms of "make things more efficient" rather than "fix a bug while attaching". Simon [1] https://sourceware.org/pipermail/gdb-patches/2021-April/177477.html