From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 185BA384A026; Fri, 5 Mar 2021 18:45:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 185BA384A026 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 125IjK9J009486 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Mar 2021 13:45:25 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 125IjK9J009486 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) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 306051E54D; Fri, 5 Mar 2021 13:45:20 -0500 (EST) Subject: Re: [PATCH] nptl: Move stack list variables into _rtld_global To: Florian Weimer Cc: Simon Marchi via Libc-alpha , gdb-patches@sourceware.org References: <87a6vlthqn.fsf@oldenburg2.str.redhat.com> <0f7bf7d7-36f9-ce7f-0390-4b39eeb0fffc@polymtl.ca> <87zgzhbjy0.fsf@oldenburg.str.redhat.com> <87mtvhbhqw.fsf@oldenburg.str.redhat.com> From: Simon Marchi Message-ID: Date: Fri, 5 Mar 2021 13:45:19 -0500 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: <87mtvhbhqw.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 5 Mar 2021 18:45:20 +0000 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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: Fri, 05 Mar 2021 18:45:28 -0000 On 2021-03-05 1:03 p.m., Florian Weimer wrote: > 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? Indeed, in that case ld-linux-x86-64.so.2 is loaded before libpthread.so.0 (ld-linux is necessarily loaded before the others, I guess, since it's the one loading the others). So the symbol is found: LOOKUP _rtld_global in ld-linux-x86-64.so.2 Found 0x7ffff7ffd000 >> 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. Ok, currently GDB attempts to load libthread_db when noticing the main objfile / program (I guess it is needed if the program is statically linked to libpthread?) or when seeing a library named libpthread*. I'm not sure how to fix this, other than making GDB attempt to load libthread_db on every new shared library it notices, since that new shared library may "finally" make it work. The current code specifically exists to avoid trying to load libthread_db for every new shared library we notice, since that was considered wasteful. Here's the original thread about it: https://sourceware.org/pipermail/gdb-patches/2011-October/085781.html https://pi.simark.ca/gdb-patches/20111005182705.D744E2461D1@ruffy.mtv.corp.google.com/ About the hypothetical scenario for glibc 2.34: do you mean that the pthread infrastructure will directly be in libc.so? If so, our current strategy of attempting to load libthread_db only for the main program or a libpthread* library will indeed not work. And I suppose that will also require trying to load libthread_db on every new shared lib... Simon