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 4A2FF3892460; Fri, 16 Apr 2021 17:33:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4A2FF3892460 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 13GHXRcR005324 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 16 Apr 2021 13:33:31 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 13GHXRcR005324 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 748BB1E01F; Fri, 16 Apr 2021 13:33:26 -0400 (EDT) Subject: Re: [PATCH glibc] nptl_db: different libpthread/ld.so load orders (bug 27744) To: Pedro Alves , Florian Weimer Cc: libc-alpha@sourceware.org, gdb-patches@sourceware.org, Emil Velikov , Kevin Buettner 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> <83364527-b4aa-b7cc-928b-10d20c4338a3@polymtl.ca> From: Simon Marchi Message-ID: <78edaf4c-e2f2-8d4e-0950-98ba24367921@polymtl.ca> Date: Fri, 16 Apr 2021 13:33:26 -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: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 16 Apr 2021 17:33:27 +0000 X-Spam-Status: No, score=-4.2 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, 16 Apr 2021 17:33:37 -0000 On 2021-04-16 1:18 p.m., Pedro Alves wrote: > On 16/04/21 17:53, Simon Marchi wrote: > >> Do we need / want to fix GDB if this goes in glibc then? > > I think so. We may need to discuss more the "needs_setup" hack, but we > can do that in that thread. In the new version I add a new inferior flag "in_initial_library_scan". It's perhaps not ideal but the result is better than what I had in v1. But yeah let's discuss that in that thread. > Given that libpthread.so is going away in the future, we should be thinking about > addressing that as well. Does your patch fix that as side effect? No, I think of that as a separate problem. > > If not, GDB should be keying the loading of libthread_db.so on something else. > Making GDB try to load libthread_db in reaction to processing ld.so instead > libthread_db.so would fix that, I think. And, it would fix this ordering problem at > hand as well. So if we do that, maybe we don't need the other changes. Is it possible to have a completely static executable that doesn't use ld.so but uses pthreads? I don't think that would work well for the "run" case, where ld-linux arrives before libpthreads.so (and before libc.so, for when pthreads is moved to libc.so). If we try to load libthread_db when ld-linux appears, the symbols provided by libpthreads (or libc) won't be found. We would have to key the loading on when both libpthread and ld-linux are there (or both libc and ld-linux). Another problem with the current state (but that would be fixed with Florian's patch I think) is that gdb has this setting "set auto-solib-add". If off, GDB won't load the symbols of shared libraries. _Except_ if the library if libpthread: https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/solib.c;h=d32b2210005fdd6a5013cfd566620d6afeae9cf6;hb=HEAD#l968 But it means that if auto-solib-add is off, we won't load ld.so's symbols, and we fall back on the original problem, even if the ordering is right. Since Florian's patch makes libthread_db only access symbols of libpthread.so, I think that avoids this issue as well. But then when libpthreads is moved into libc, we'll have the problem that libthread_db simply won't get loaded... Simon