From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id dgn7LrNJ/Wl9kSAAWB0awg (envelope-from ) for ; Thu, 07 May 2026 22:25:55 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=cB9XuaBH; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A96171E093; Thu, 07 May 2026 22:25:55 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham 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 F372A1E093 for ; Thu, 07 May 2026 22:25:54 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B15044BA2E24 for ; Fri, 8 May 2026 02:25:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B15044BA2E24 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=cB9XuaBH Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 426524BA2E0C for ; Fri, 8 May 2026 02:25:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 426524BA2E0C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 426524BA2E0C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778207128; cv=none; b=xo98A+4nyK9E4pWP3HN4Fsh9AQZC2o9sQkTT71RFA3TcSBjPwIF3dEgEdPK8WK/5X/j0WEIxUCvpQimWaygP0fWCDJhrTuqLJ/YOXd4tbEYfQhXQ1D1xCV5vw82mqjeDWQWzC43NIb1dGL5m9I1swJGOhI4gQskb9oO11crIC9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778207128; c=relaxed/simple; bh=FirZYnZ/F1MTm2ZPfwqRL5juypDlS17b8G1Dd8LiFcc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=vr51mg2ilF7Vh1BvyCf6Xn9stpvCW1O5m8kiiKR8IbF4GdZv1dYK4lBdP3fgfUylG2Hua6K2K6PxJVqUNUBH9M+z+nlSWWIUF1Zn3JHKEC4aQ551ORFlZI42wD/VHvmnKIpkcc6p/LVaWG2X59oSE7aJoYMTWrceNQQYJRu9IFE= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=polymtl.ca header.i=@polymtl.ca header.a=rsa-sha256 header.s=oct2025 header.b=cB9XuaBH DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 426524BA2E0C 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 6482PL93134034 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 7 May 2026 22:25:26 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 6482PL93134034 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=oct2025; t=1778207127; bh=wqMorCtbUOkbDFuyZTWFpmG4UHYq82BWGRPKMCJf8yQ=; h=Date:Subject:To:Cc:From:In-Reply-To:From; b=cB9XuaBH3RxRPP8BzFPya5dpf64XQUQZlPCdYLy48weiq71EwYwXXr5gwzfOwPZN4 khsrPs9AAycK14wEy9GnDa/V4CSGLDSXPX6PDLSoGQGEARqnvGaDJtMzpslbVlI7+w 91Pmb+YQfH0pAHU1SxmfCVhQ4/FXHG6h7RyCjiM5zNoGqmxI8OcMwoZdiw1ezIuzTx Vr6ZwHHP3btwDzyxnEETgKUPk7iYrTsZQjQTTUyObfAU//WRyo5wyq2iqleX+15v+M Nc9qZMxZT2qoNqUNi2vYd0esWKWxcDVF4z7CM+Izk2bNCywcxBLIk7zj3mVCmJ9hgn HbXp6JjrmpaIw== Received: by simark.ca (Postfix) id 4CA151E093; Thu, 07 May 2026 22:25:21 -0400 (EDT) Message-ID: <65bfee31-e375-4460-9327-e80fb3e2d244@polymtl.ca> Date: Thu, 7 May 2026 22:25:20 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 09/11] gdb: add objfile -> solib backlink To: Tom Tromey , Simon Marchi Cc: gdb-patches@sourceware.org References: <20251209193610.296085-1-simon.marchi@efficios.com> <20251209193610.296085-10-simon.marchi@efficios.com> <87o6j3kq0p.fsf@tromey.com> Content-Language: fr From: Simon Marchi In-Reply-To: <87o6j3kq0p.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 8 May 2026 02:25:22 +0000 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 On 4/28/26 12:28 PM, Tom Tromey wrote: >>>>>> "Simon" == Simon Marchi writes: > > Simon> However, I learned that there may be more than one solib linked to one > Simon> objfile, so this backlink is actually a vector. > > How / when can this happen? It seems surprising to me, except maybe for > separate debug info. The only case I'm aware of is the dynamic linker itself. It appears in all namespaces, with the same load address. We get one solib for each "view" of it, but all these solibs point to the same objfile. I think I learned that around this time: https://gitlab.com/gnutools/binutils-gdb/-/commit/d33a66a31134bd63c4945d0d570e7296aaac3574 I will make this sentence more precise. > > Simon> @@ -732,10 +733,14 @@ remove_solib (program_space *pspace, > Simon> notify_solib_unloaded (pspace, *solib_it, still_in_use, false); > > Simon> /* Unless the user loaded it explicitly, free SO's objfile. */ > Simon> - if (solib_it->objfile != nullptr > Simon> - && !(solib_it->objfile->flags & OBJF_USERLOADED) > Simon> - && !still_in_use) > Simon> - solib_it->objfile->unlink (); > Simon> + if (solib_it->objfile != nullptr) > Simon> + { > Simon> + /* Remove the objfile -> solib backlink. */ > Simon> + solib_it->objfile->remove_solib (*solib_it); > Simon> + > Simon> + if (!(solib_it->objfile->flags & OBJF_USERLOADED) && !still_in_use) > Simon> + solib_it->objfile->unlink (); > Simon> + } > > Doesn't this mean that if one solib is removed, then other solibs with > the same objfile will have a dangling objfile pointer? I don't think so because of the still_in_use check, which is initialized with: bool still_in_use = solib_it->objfile != nullptr && solib_used (pspace, *solib_it); solib_used is: /* Return true if KNOWN->objfile is used by any other solib object in PSPACE's list of shared libraries. Return false otherwise. */ static bool solib_used (program_space *pspace, const solib &known) { for (const solib &pivot : pspace->solibs ()) if (&pivot != &known && pivot.objfile == known.objfile) return true; return false; } If another solib points to the same objfile, we won't unlink the objfile. "solib_used" is not the best name for this function. Simon