From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id W/3lI1BxQmAkFwAAWB0awg (envelope-from ) for ; Fri, 05 Mar 2021 12:58:40 -0500 Received: by simark.ca (Postfix, from userid 112) id 858881EF78; Fri, 5 Mar 2021 12:58:40 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED 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 (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C3E4A1E54D for ; Fri, 5 Mar 2021 12:58:39 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2787D383540C; Fri, 5 Mar 2021 17:58:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2787D383540C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1614967119; bh=F80FKLVl54iO6xlAvnlMjPdG8voXbeGRKcxUXdlYSJM=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=qaOdVr/qhA/jhiN3myl9uKpbDeT7CSxjo2frLaHvboBvro4fEwyMvmoYgHYmDFl5H muB1XzNb4TeJwsHD1M475F+Q65CkzD42QBLweyYSkCQwqDeyasKG1bBOZHA6a9nWgM 6aMFn3dDhkiaZ9oMAa33QXFMoNRADHAa2fJgI4ac= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 59FD03861836; Fri, 5 Mar 2021 17:58:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 59FD03861836 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 125HwMoL011548 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Mar 2021 12:58:27 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 125HwMoL011548 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 21D301E54D; Fri, 5 Mar 2021 12:58:22 -0500 (EST) Subject: Re: [PATCH] nptl: Move stack list variables into _rtld_global To: Florian Weimer , 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> Message-ID: Date: Fri, 5 Mar 2021 12:58:21 -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: <87zgzhbjy0.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 17:58:22 +0000 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: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" 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. For comparison, glibc 2.31 (on Ubuntu 20.04) only requested symbols in libpthread itself, so there wasn't this ordering issue: LOOKUP nptl_version in libpthread.so.0 Found 0x7f38538e9037 LOOKUP __stack_user in libpthread.so.0 Found 0x7f38538f3350 LOOKUP _thread_db_list_t_next in libpthread.so.0 Found 0x7f38538e93b0 LOOKUP _thread_db_const_thread_area in libpthread.so.0 Found 0x7f38538e92b4 LOOKUP _thread_db_sizeof_pthread in libpthread.so.0 Found 0x7f38538e92cc LOOKUP _thread_db_pthread_specific in libpthread.so.0 Found 0x7f38538e9400 LOOKUP _thread_db_pthread_schedpolicy in libpthread.so.0 Found 0x7f38538e9420 LOOKUP _thread_db_pthread_schedparam_sched_priority in libpthread.so.0 Found 0x7f38538e9410 LOOKUP _thread_db_pthread_tid in libpthread.so.0 Found 0x7f38538e9450 LOOKUP _thread_db_pthread_cancelhandling in libpthread.so.0 Found 0x7f38538e9430 LOOKUP _thread_db_pthread_report_events in libpthread.so.0 Found 0x7f38538e9460 LOOKUP _thread_db_pthread_start_routine in libpthread.so.0 Found 0x7f38538e9440 LOOKUP _thread_db_pthread_eventbuf_eventmask_event_bits in libpthread.so.0 Found 0x7f38538e93d0 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. Simon