From patchwork Thu Oct 18 22:05:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 29792 Received: (qmail 28740 invoked by alias); 18 Oct 2018 22:07:47 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 28729 invoked by uid 89); 18 Oct 2018 22:07:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=sk:obstack X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.145.23) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 18 Oct 2018 22:07:46 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway33.websitewelcome.com (Postfix) with ESMTP id A1D4E2452C for ; Thu, 18 Oct 2018 17:05:39 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id DGQ1gRG0itz4jDGQ8gYXAi; Thu, 18 Oct 2018 17:05:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=k3mB1vQ5pnHFBRcUKn+F4W3oHJQSVEeNzW4OpQReXPg=; b=g9ohB2NqXcxoT5I6lG/iBGwrDR XLUfQaMf9OCif0RnqtQDmZdqrR3ICsRI3LqJQSVZcAAgLbePZiZBTYe1Etlx3JdXZ9l9K5YhCWAqI DSsOpKH88jiCQ5h6aKH7GRsA1; Received: from 97-122-190-66.hlrn.qwest.net ([97.122.190.66]:49770 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1gDGQ0-002eOU-TZ; Thu, 18 Oct 2018 17:05:25 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Clear static_links in reread_symbols Date: Thu, 18 Oct 2018 16:05:22 -0600 Message-Id: <20181018220522.28062-1-tom@tromey.com> -fsanitize=address pointed out a use-after free in objfile_register_static_link. The bug turned out to be that reread_symbols does not clear the static_links field; this leaves a hash table that is filled with freed pointers. Jan's (now quite old) idea of replacing reread_symbols with a simple delete/new still seems good to me, and it's worth noting that it would have avoided this bug. Tested by the buildbot and by observing the change with -fsanitize=address. gdb/ChangeLog 2018-10-18 Tom Tromey * symfile.c (reread_symbols): Clear "static_links". --- gdb/ChangeLog | 4 ++++ gdb/symfile.c | 1 + 2 files changed, 5 insertions(+) diff --git a/gdb/symfile.c b/gdb/symfile.c index 6a1140edbc..8ab6a25de7 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2497,6 +2497,7 @@ reread_symbols (void) objfile->psymtabs_addrmap = NULL; objfile->free_psymtabs = NULL; objfile->template_symbols = NULL; + objfile->static_links = NULL; /* obstack_init also initializes the obstack so it is empty. We could use obstack_specify_allocation but