From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 7z59GA42+mnVGhcAWB0awg (envelope-from ) for ; Tue, 05 May 2026 14:25:18 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=A7ih9LqY; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 51E5A1E067; Tue, 05 May 2026 14:25:18 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C6E471E067 for ; Tue, 05 May 2026 14:25:17 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 77B634BA799C for ; Tue, 5 May 2026 18:25:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 77B634BA799C Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=A7ih9LqY Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id CDBC84BA2E23 for ; Tue, 5 May 2026 18:24:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CDBC84BA2E23 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CDBC84BA2E23 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778005491; cv=none; b=kJMEhdis353QW/AS+sq55iue0GiS/eGSUSThlzWOvRyVvUOpGq00TiO5T/y5Qn1+/I0M0GRZ/LWPp8qtcpYrWYoZgZwYHUy7XvNZ3a7v7SW/nrY7yPBiSYDfpQGdD8DfHuE87JndDIuMNl6q19qEjLuElYSv+cMfcLcgNx3Lp0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778005491; c=relaxed/simple; bh=fXQJq1ANdRwIk39idHsGkucZtX5fyoxNd/PuGsESIJA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=JoD9OFFDx/cY6WFOVDuLd4/ftZP/CFtzDpIZOODbQ7M44xr2D6ZHFbPDgXzAXnVJipohYyiB1TPuEHou8Nf9cAkIZP+qKb+YHL0hmIZFAbwkQzxpu7pqHIrHCvpsUsyUT6xWa7uL80VAgL1iqQVUta1xVDcydaPBVJ9l38j4F54= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CDBC84BA2E23 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778005491; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1qZnMkCyIGtUdXIMWZFoP2FQCwMKZL492yqGMpyjgNo=; b=A7ih9LqYoEVr+QeNTp9eR5pLig2ZyPsRztkxE8CcKO/tqEtyyVuUrikBWP9KHsNgmHOdOV rjHvxHV82m6oaJr0V317eQvZpRc4K7GWWZDqluT8pDLvFGWrKcXBr2LpPmWL01uA+cKZtS 5E6TDJk3Ex8BwETwtD8O10/uRFz69VM= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-675-PDAaVJPQMeOJZJuHkmdIBg-1; Tue, 05 May 2026 14:24:50 -0400 X-MC-Unique: PDAaVJPQMeOJZJuHkmdIBg-1 X-Mimecast-MFC-AGG-ID: PDAaVJPQMeOJZJuHkmdIBg_1778005490 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-902de1c513bso59429585a.0 for ; Tue, 05 May 2026 11:24:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778005489; x=1778610289; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1qZnMkCyIGtUdXIMWZFoP2FQCwMKZL492yqGMpyjgNo=; b=Mq14jYrRZZxT1PtbeEJ8/qbYzMPXxHj/YVWY9+VDoRqLcz1YLSR3PLWXNOsA+UOh5s hF21dBoLobKswiJw8i8I3LaL27Y8HivL/uEJ1yQdHbNE4yg712QED3DsJwY8aMCFnd0J r1S3IyfDNdcgYKozeGlKQ2gzJ7d/Qgp5B0DLH0VNzwzcyH5LwURtBFQ9+ummlKzL5LVG iyLKBdotXX3OrrrwYupXhhSVEyc0qs83V2fsNcF0H768wmd4gR+q43bkKfqRiG6jrBoM OsyZs7RKkoBYJy/RiEOYhA/8GfV5o23Llbk7PXYOs/VF03gJ6B8duOR3mMikByl7I+ed DcmA== X-Forwarded-Encrypted: i=1; AFNElJ8ChfnI6eGSimgGrrizu2oej2WlcOwsyLL8fxcZqfLN80Wsgwd8FTOTD0LUy/+9vD3JaEHz127diAzkTg==@sourceware.org X-Gm-Message-State: AOJu0YwDhifVZIh+6+QdnQp1UlDRTU1gsKJIpxiSUBctryZZwgkWKejg 6kdP36m9JaZ5j5ZYBLeCM0jvYtKMXMsZljEEaBskHg1Ol2x5xGQlec3WmlH35AxNr52HcHQ19hI rAk6K3nforFhSMk/HAkCUQEsS7vJk5fLsXEc+yQ7BMLZLg+1HcI/nO95aWlXcyUGlgZqTIck= X-Gm-Gg: AeBDiettjsUy/pUTLSNgPVXUyNrqrho9AA0Pepa+1G6zpu9XJnf4mtHgot4k5uCeXVd 6XCu9opP/hMRd6srTUuMlHAOSpN0kiN3Q00FsEJexVXsRVNJ70aagqgl4J7TE/pfcYpz+RNEHt2 dyyR5QriZnRDA2IfoJb6u1YHvfxMo6AMN34oX14EHfcD7zUZwCtbL9FNdLTqkWSPBeoT5khXjMY mTkTmfX9PM3g5wlA4Gdn56Ha4/VVuT7dUc4aJnHw0gg3INnZ55523mIZ0CFEGXwpAyRPnYEdPEG Tu5BV6ByNnpisxI2hb1tXV9xsMMEiPUolfqqo6p9ZN9w746l0QepCx1I5qoNk3umx6mtfHlYwPN dF7eadv8Akt6dAt0GH5XPLpyD9ZR0huT1tYlk7Ik= X-Received: by 2002:a05:620a:4489:b0:8cd:8e8a:3584 with SMTP id af79cd13be357-904d5ffde97mr21079485a.11.1778005489540; Tue, 05 May 2026 11:24:49 -0700 (PDT) X-Received: by 2002:a05:620a:4489:b0:8cd:8e8a:3584 with SMTP id af79cd13be357-904d5ffde97mr21071285a.11.1778005488668; Tue, 05 May 2026 11:24:48 -0700 (PDT) Received: from [150.1.200.157] ([172.56.105.115]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8fc2c349572sm1445164385a.28.2026.05.05.11.24.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 May 2026 11:24:48 -0700 (PDT) Message-ID: Date: Tue, 5 May 2026 11:24:46 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/3] gdb: add some asserts to thread_db_notice_clone To: Andrew Burgess , gdb-patches@sourceware.org References: <2c5f44442eacd91020ce9058abf16442ecf3718a.1775557188.git.aburgess@redhat.com> From: Keith Seitz In-Reply-To: <2c5f44442eacd91020ce9058abf16442ecf3718a.1775557188.git.aburgess@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ztPT_aGeI3CY8ZtGMTJYX0cB_XFfjncsRoh0EbUm3_g_1778005490 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Hi, On 4/7/26 3:22 AM, Andrew Burgess wrote: > This commit adds some asserts to thread_db_notice_clone, and reorders > some code. This is really just a refactor ahead of the next commit. > The changes made here are: > > 1. Add an assert that STOPPED is not NULL. We pass STOPPED as the > first argument to thread_from_lwp, which already assumes that the > pointer is not NULL. If STOPPED was ever NULL then we would have > hit a segfault in thread_from_lwp long ago. > > 2. Move the thread_from_lwp call relating to the PARENT thread > before the call relating to the CHILD thread, and assert that the > value we get back is STOPPED. The thread_from_lwp might also > gather thread-db related information about PARENT, so the call is > important, but even if PARENT cannot be managed via thread-db, > the result we get back should always still be STOPPED (see > record_thread for more details). Moving this call before the > call relating to the CHILD thread makes the next commit cleaner. > > There should be no user visible changes after this commit as I believe > both of the things being asserted have always been true. I'm no expert at this, but your assumption seems correct as far as I understand it. So this LGTM. Reviewed-By: Keith Seitz Keith > --- > gdb/linux-thread-db.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c > index cd25c55a898..1807352ed76 100644 > --- a/gdb/linux-thread-db.c > +++ b/gdb/linux-thread-db.c > @@ -440,12 +440,17 @@ thread_db_notice_clone (ptid_t parent, ptid_t child) > return false; > > thread_info *stopped = linux_target->find_thread (parent); > - > - thread_from_lwp (stopped, child); > + gdb_assert (stopped != nullptr); > > /* If we do not know about the main thread's pthread info yet, this > - would be a good time to find it. */ > - thread_from_lwp (stopped, parent); > + would be a good time to find it. This should return the same > + thread_info as STOPPED, but a side effect of this call is that the > + pthread/thread-db information might have been filled in if it was not > + already known. */ > + thread_info *parent_info = thread_from_lwp (stopped, parent); > + gdb_assert (parent_info == stopped); > + > + thread_from_lwp (stopped, child); > return true; > } >