From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2088.outbound.protection.outlook.com [40.107.96.88]) by sourceware.org (Postfix) with ESMTPS id 0E1BF3857B82 for ; Fri, 17 Jun 2022 10:10:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0E1BF3857B82 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f8/W81IsUP4KuWDuM/awe26mBMbD+XfR1wsWlf+qBYf8IFdL/gGCyy9QUiSM5j7SY3AIaVHdNXZVGX/v0r4kdZHnJhJ/CaRgEQcvE7uGdbgq60UM+UBuWD3Vx5+VUWn26I9TsHuKrT8J8CpTiGavnwJf4Y4/OupMJ3v8vPNQag+1sMD87o3A684CyCqEf8SAJzX8bdBMccxHcj92pNrgMMvok40yNeo4j6VTZLZz0lr/gVKXo03P02473L0pd4wbsgbSv6r0SZqZUQAUZXiqLrtwHsjS+VAqSTr2FMSxfTlH4Ca3gE2/Urc1rJiQI5AJXxVJmMDjVnUzKE+8K52gOQ== 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=Jv84BYmlZI0OzS2tUAnq2JOV0piJgAh/OzldSSFebyg=; b=K1ebPGPnFz3Ooo2k7JkFta+b2yxEYWLleM/PeZezfFlu9lYu7yfIEIQOdhjOAthluy7TX0/B5MV1KDdc7IrgQHksjayZxS7sM/CklA1web6RSzLvtwOzgNPOIqEgIFRcKoJU2hjbvd6QjTHB5S5DpXqmRSbhmS+43qYxoymSR6diNSrTK4/NGt3Ii8MN56gRKk+LmRb3bdq0xj8CperXFpiBWHXav8ctIn1nkEmxU/fAPFUj18fuFe5z5MiR/MbMttvYhIpgk1hgtAUFeB2GwQYn/8v4cBy+H7N+ZRFkwVd8IeJyCv4Gt3wuoWUOfYEfFcDVG78hpF8pxQg6RT7q8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=sourceware.org 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 Received: from MW4PR02CA0027.namprd02.prod.outlook.com (2603:10b6:303:16d::32) by MN0PR12MB5812.namprd12.prod.outlook.com (2603:10b6:208:378::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.16; Fri, 17 Jun 2022 10:10:48 +0000 Received: from CO1NAM11FT039.eop-nam11.prod.protection.outlook.com (2603:10b6:303:16d:cafe::40) by MW4PR02CA0027.outlook.office365.com (2603:10b6:303:16d::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5332.14 via Frontend Transport; Fri, 17 Jun 2022 10:10:47 +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 CO1NAM11FT039.mail.protection.outlook.com (10.13.174.110) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5353.14 via Frontend Transport; Fri, 17 Jun 2022 10:10:47 +0000 Received: from khazad-dum.amd.com (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.2375.28; Fri, 17 Jun 2022 05:10:45 -0500 From: Lancelot SIX To: CC: , Lancelot SIX Subject: [PATCH 0/3] Fix some use-after-free errors in varobj code Date: Fri, 17 Jun 2022 11:10:21 +0100 Message-ID: <20220617101024.2830260-1-lancelot.six@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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-Office365-Filtering-Correlation-Id: 056b1af3-fd9f-4d65-cbdf-08da5049a62a X-MS-TrafficTypeDiagnostic: MN0PR12MB5812:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NT9JLk/ujvLT+IiWVoGFCHMtOzhJKjcH64ue5iz5fZZYdSmVv3ZVe2p+W3QzuehRXvH+h6i1pKZpKbUNfhWI97778TAv1wQl+xuN3dZfXv4JjyEFrDursjwHFlliS0cnJ2fGQn+4Q7pBwbQeaq5Q1fDGL9DaOpVXzbjlG7RiQ8qlfCORv+WCL/8ZH1XGksahQ9He4K8rnp/orCW1u1sxTN9hCf4RfR1+UCOH1lO073q+ITcWXtdlxNkCjdsnJz+3MzMGmC7iaTdsMjUfSkvoehllfqwnqZgSjS0xRsLLHoHdTtehWS2V4lQKCvbiNxlKQgVRJa8oBN8+Ftw4YTt4aeStud81YwkM+Dxce+Irk7eaTIC0mblEDMmO9RSaE9ayP4zSt0gYz8pUB4fsOvMMlWGJ31hvGXwxvC74g/ZyYTjUjxPT4sPgT8I7dGayiVxqHrUqJI2WIzUOMRk6eaXX/UpIVbvplyrlORgMZmljLdJsBANQPOE4CH/kJnnsFhjC6jyFEIZn5olOLgKm91bQvnbp2JRIDcGULj6BI4gmNEpTs+PDURHnjjXKfbcDJ+ltYC/e0jcqZW23RtbVbSFwe1q2D4VklOZgculLRq9n0wdKm93WYxibvWRl2Q7ZsLv9htXkHnNx+Kaaq88DwAI4lKvbf1awxwcWxKMCmpGNkO9/ZqHcv9f4Y0B11h5agLHVLre2l37QuTgDm+tJVIX6nw== 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:(13230016)(4636009)(40470700004)(36840700001)(46966006)(7696005)(8936002)(5660300002)(70586007)(8676002)(4326008)(6916009)(70206006)(6666004)(316002)(86362001)(54906003)(81166007)(356005)(508600001)(36860700001)(82310400005)(16526019)(186003)(1076003)(2616005)(426003)(36756003)(47076005)(336012)(83380400001)(40460700003)(2906002)(26005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2022 10:10:47.5128 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 056b1af3-fd9f-4d65-cbdf-08da5049a62a 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: CO1NAM11FT039.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5812 X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2022 10:10:53 -0000 Hi, This series aims at fixing some use-after free errors we have observed around the varobj code. When a objfile is freed, the varobj can keep references to the objfile and to objects that used to live on the objfile's objstack (types among other things). This can mainly be observed when debugging code which loads and unloads shared libraries during its lifetime. Without such scenario the problems exist but are rarely exposed as the references to freed memory are not used. The first patch of the series was originally written by Pedro. It improves mi-support.exp so `mi_runto` now accepts a `-pending` flag, which will be used in the following patch. Patch #2 fixes the actual use-after free errors by ensuring that we clear all references to the objfile before it is freed. Patch #3 fix some inaccuracies in the current varobj_invalidate mechanism which is used to invalidate/recreate varobj when loading a new objfile. All feedback are welcome. Regression tested on x86_64. Lancelot SIX (2): gdb/varobj: Fix use after free in varobj gdb/varobj: Fix varobj_invalidate_iter Pedro Alves (1): MI: mi_runto -pending .../gdb.mi/mi-var-invalidate-shlib-lib.c | 30 ++++++ .../gdb.mi/mi-var-invalidate-shlib.c | 27 ++++++ .../gdb.mi/mi-var-invalidate-shlib.exp | 91 +++++++++++++++++++ gdb/testsuite/lib/mi-support.exp | 68 ++++++++++++-- gdb/value.c | 21 +++++ gdb/varobj.c | 86 ++++++++++++++++-- 6 files changed, 308 insertions(+), 15 deletions(-) create mode 100644 gdb/testsuite/gdb.mi/mi-var-invalidate-shlib-lib.c create mode 100644 gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.c create mode 100644 gdb/testsuite/gdb.mi/mi-var-invalidate-shlib.exp base-commit: 5fb28d2607a8325559b44a5dc0c8760236c81218 -- 2.25.1