From patchwork Tue Sep 23 14:47:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 392546 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 29CFF140095 for ; Wed, 24 Sep 2014 00:48:13 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=Ee7z3VIuztkhl7mm HJY7ZS4bwIBOfGV/bTSO5rIxnRagqSH4SAgrgJmX1GM7w0Rlk2MjHcSKyErUkVAX mSBC7E7mqAkMNjCkeEx57Gu5oq0KJdwNwMBUYxH5vzk+osCGhKvSZlRZgEMMqPJ7 J8iRZTegm3g0sj0kGP9m3rKcimk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=xTY42pgDdPaxHqkwp4tUfA iX15g=; b=Z37GRI+HBL7Vik1co1aVJNz4rbv+LocLxTS9+hTYgjxROVVR6zBgga olT+QK7Hpkeye8K/5/fGjbrJxJRa1G2nJpqfIXOKLbM3VI0I//+ysPDxkFE/l/0m 3c8ATk5iR/tVqx+6po5D8RKL/pRPKkxDlbbt8yeKieGsUANuZlA0k= Received: (qmail 4344 invoked by alias); 23 Sep 2014 14:48:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 4223 invoked by uid 89); 23 Sep 2014 14:48:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 23 Sep 2014 14:48:02 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 23 Sep 2014 15:47:59 +0100 Received: from localhost ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 23 Sep 2014 15:47:58 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [committed] PR 63280: Misplaced destructor call Date: Tue, 23 Sep 2014 15:47:58 +0100 Message-ID: <87mw9ql7fl.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: 114092315475902001 My patch to fix a memory leak with target_globals accidentally introduced a double destructor call for default_target_ira. Normally this was benign because free_register_move_costs clears the freed pointers afterwards. However, with LTO -O3 that clearing could get inlined into the destructor and removed as dead, leading to a double free. Tested on aarch64-elf and applied as obvious. Thanks, Richard gcc/ PR bootstrap/63280 * target-globals.c (target_globals::~target_globals): Fix location of ira_int destruction. Index: gcc/target-globals.c =================================================================== --- gcc/target-globals.c 2014-09-22 08:37:01.421320931 +0100 +++ gcc/target-globals.c 2014-09-23 15:44:48.951451849 +0100 @@ -121,10 +121,10 @@ save_target_globals_default_opts () target_globals::~target_globals () { - ira_int->~target_ira_int (); /* default_target_globals points to static data so shouldn't be freed. */ if (this != &default_target_globals) { + ira_int->~target_ira_int (); hard_regs->finalize (); XDELETE (flag_state); XDELETE (regs);