From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iX74HHtIBWb4YRkAWB0awg (envelope-from ) for ; Thu, 28 Mar 2024 06:37:47 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=A3vguoiF; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 55D9C1E0C0; Thu, 28 Mar 2024 06:37:47 -0400 (EDT) Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 248791E030 for ; Thu, 28 Mar 2024 06:37:45 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BC1053858C3A for ; Thu, 28 Mar 2024 10:37:44 +0000 (GMT) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2079.outbound.protection.outlook.com [40.107.237.79]) by sourceware.org (Postfix) with ESMTPS id 818ED3858D1E for ; Thu, 28 Mar 2024 10:37:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 818ED3858D1E Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 818ED3858D1E Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.237.79 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1711622245; cv=pass; b=Oz+qSOJL7FBX6TrbhKeqt5K8i23daVAb5LbZmUKZt6RXPZ504fFMZASKwNWkdr+z0RGPC8n209dHIB5vE5rE+unOe5k5DjT1IiaspJWLOsdfXWNDJS6EfMc1Tc/v+tFZd2RKMahEZrhn2AVbF8MPslO8oiN0t6CqbAdUfDejK7s= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1711622245; c=relaxed/simple; bh=KLqH0Z3zupWMORUVqb/kwNw9lnD7Ty3zEO6Ph05QJz8=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=sHLZw0PYNN99zc5VRNjCfytTNqvTaOypibg8zpsH10KLOscnUwe4O4HdLb/qH9Y+1BaUzXLSP/mwzHZspXAX5Baz5FfhPHka62F9JAbZOM9UzRhT7JSN8N7O89XCNYRoAIS0mWyjknwKEDo7FJkqtpejWebkqW+oaMjtvU/dDlo= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hfVYXdtAp6J1r/pV91Mg+i5jAPZzUjsrMU71FWmQhyMOioSktSmUT2fnqJnOWEUp1Yazvp0u2u3ab6hLhoxOjiCTJNiWbW16sVCjG+/obD5A8s5tQgc6KYF+3rE7pejWaG2F5fRE4PteO3xv6FdLLQVvAsxV0/M37ne5ERbhGmAtO5j0r43feQtYMrfgsMTzpaJkkad5jWij2BcSzBpkuno7luw27nWNz+wHulZOFAiP3Q3e+N/dG5cX4kSivapjEDB33H1fbsleuz9JRt3AWjOUloFLG0SL9lIf3S/wBDexky5KqtZH3CyK5nTRYEn/PMuivAzMqhW1IYPl8KHoUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+RiO6uSDqq0kuMSu/g2DwqcjJyLHXGgivBV4AmtgRl0=; b=j6WB3325QkNYZ7P/8fVROCRbOLiKAmLtNzoCYBQqzECAoJFOt8vfpom+iJVLempndT5xwa2ZC+SqpFBz74XXyEUq5fTgzPhbHmUnME3eJghVWbwXZE5hQs0/APklRaqHhufxOE5fuKBZ3jeR4ATL++y3+akfSBRKCbKHbl5A887VaRWKQeHstmm5kgwtrFOU1OEnbd8T5yenjGmCex5ij2s4JRFBugp78j5BbrgfyfDmBVEBVfF2/ccI1VSA+aT8IMg7P6TY+xvlJ24oFRnGE8G8w39Wy9S9/sLaf88nG0Zei34oKROdyLfZxTWonan2eExMEvE71pMpm7McWqg7Dw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=tromey.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+RiO6uSDqq0kuMSu/g2DwqcjJyLHXGgivBV4AmtgRl0=; b=A3vguoiFHVByaGCF/wvqTngkJ7X5c8zxcwM1BjqvoeUAHnZQRgPJeNctI5ahLPnxyiI5H7RSghSl23kbLM7SWf+UXrx4GIgNx+mti2F1Kpggb4XszkMXyNZ8+DtugqvrHy197n5tYKubhoy1iKKrz24Mg62U6gLCme0IWJm1wzU= Received: from DM6PR03CA0029.namprd03.prod.outlook.com (2603:10b6:5:40::42) by PH8PR12MB7133.namprd12.prod.outlook.com (2603:10b6:510:22e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.38; Thu, 28 Mar 2024 10:37:15 +0000 Received: from DS1PEPF00017094.namprd03.prod.outlook.com (2603:10b6:5:40:cafe::b3) by DM6PR03CA0029.outlook.office365.com (2603:10b6:5:40::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.13 via Frontend Transport; Thu, 28 Mar 2024 10:37:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF00017094.mail.protection.outlook.com (10.167.17.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7409.10 via Frontend Transport; Thu, 28 Mar 2024 10:37:14 +0000 Received: from khazad-dum (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 28 Mar 2024 05:37:13 -0500 Date: Thu, 28 Mar 2024 10:37:04 +0000 From: Lancelot SIX To: Tom Tromey CC: Subject: Re: [PATCH] Avoid race when reading dwz file Message-ID: <20240328103632.7iljwbcnjm55rkgd@khazad-dum> References: <20240125135129.977108-1-tom@tromey.com> <877ciczufp.fsf@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <877ciczufp.fsf@tromey.com> X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017094:EE_|PH8PR12MB7133:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c12363c-b764-41db-cfe3-08dc4f1308c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: psIt1KCceFVCMRducWUyWK8fTRui5n4v9aECZ09Ojn1vST6X5kKy7OKtF9ug9SS1KD+Bg2YOkt6bPByDbZ9XuqZwwmtAr/2cNHO1rkfHQgyydgzcuOBGwShPhGFsVo6AoCKwPlJpxl0R7uu6BQeQmeARAfAkBfx6OeGWNp6LxhOHdG7VDWR/M3eolgjq/JatqBcAFvGlyPoh64JuDs4aBK7ZSBRefFREDi2wDUqfRV52S3AD5+uzm6RYbr1PX11HOTAHyK1T5w+Wt5EVEZgyrUnYNLATyGlxOY+nqaTtg5SoFLzlmW19LrvG0tLKTtUWBbBji46L0iXwmEV6z6E+CLT3gTKkSEMJepYgUGBnDJ9oUes/s6obvlT3r8SiRggYK6YHDMu53+rdsr58zU/IIBh8oaQu9rjmELuLsye5BEOW2uNAe47NbMKlpo0hquhJr4hqlzesTG1HLZDHfn5iXRu6BJ/y7jnJcIOjiQLTestsjjzL2eMhlhk4VIS8m6DzXSHwj/5l3scxGIk6Cs6E2w8i1QZV2Ccw+8C+FqlCN6BLlX9emv0+mQ4y1TSaJxjQUczVJ9Tt/VKM3wiPIocffM6IrkvZkFSvI85VkfOtGAfPJYa+PD5y9zidfT2TUrtOjtSSruN0h1nrRD5L45Sr6nGPbCYP3u894F4Yy8FcWWLFhqIw/OTwhZfH4z1ag/kLBa4d1mrEHBxd21jnh1lEcA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(376005)(36860700004)(82310400014)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Mar 2024 10:37:14.8722 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3c12363c-b764-41db-cfe3-08dc4f1308c1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017094.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7133 X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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 Fri, Mar 08, 2024 at 07:09:46AM -0700, Tom Tromey wrote: > >>>>> "Tom" == Tom Tromey writes: > > Tom> PR gdb/31260 points out a race introduced by the background reading > Tom> changes. If a given objfile is re-opened when it is already being > Tom> read, dwarf2_initialize_objfile will call dwarf2_read_dwz_file again, > Tom> causing the 'dwz_file' to be reset. > > Tom> This patch fixes the problem by arranging to open the dwz just once: > Tom> when the dwarf2_per_bfd object is created. > > Tom> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31260 > > I'm checking this in. > > Tom Hi Tom, It looks like this patch introduces a slight behavior change, and I am not sure if this is intentional (or desired). Before this patch we had: bool dwarf2_initialize_objfile (...) { if (!dwarf2_has_info (...)) return false; ... dwarf2_read_dwz_file (...); } This meas that dwarf2_read_dwz_file is only called if dwarf2_has_info returns true. Since this patch, the call to dwarf2_read_dwz_file has been moved inside dwarf2_has_info. As a consequence, dwarf2_read_dwz_file can be called in cases where dwarf2_has_info returns false. I can observe this on ubuntu-22.06 when loading /lib/x86_64-linux-gnu/libtinfo.so.6 (provided by libtinfo6). That file has no .debug_info section, but has a .gnu_debugaltlink section. The old logic would skip dwarf2_read_dwz_file because of the absence of .debug_info, but the new behavior tries (and might fail) to load the debug information referenced in .gnu_debugaltlink: $ ./gdb/gdb -data-directory ./gdb/data-directory -q /lib/x86_64-linux-gnu/libtinfo.so.6 Reading symbols from /lib/x86_64-linux-gnu/libtinfo.so.6... warning: could not find '.gnu_debugaltlink' file for /usr/lib/x86_64-linux-gnu/libtinfo.so.6.3 (No debugging symbols found in /lib/x86_64-linux-gnu/libtinfo.so.6) (gdb) I am not too sure if it makes sense to try to load the debug info referenced in .gnu_debugaltlink if the "main" debug info section is missing. It can be better than nothing as it can provide some types information, but it is definitely not sufficient for a "full" debug session. Should the call to dwarf2_read_dwz_file be guarded only if "main" debug info sections are present? I can prepare a patch doing this. [Arguably, .gnu_debugaltlink should also be removed when stripping the debug information, but it is not.] Best, Lancelot.