From patchwork Wed Jun 27 09:52:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 167582 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]) by ozlabs.org (Postfix) with SMTP id 14C67B7016 for ; Wed, 27 Jun 2012 19:53:23 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1341395604; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:From:To:Cc:Subject:References:Date: In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=XzaoncBofRSGnCP7w2P9 Ct54dL8=; b=rLf0/Mp1MP7BCC8KilBntziUf2u+3PZGFzCW0sgjVDi7L6/Rh7a/ iprmczgaalEWGhsfBYIhb7d70GIwuTerqx1ch2OVClYTa2KmHVYFYmk9/h53Kp3P ZRjHlhYi7ulx7OiyvjhpRwIkPVjztaBmROU8rULrLh6wa1xvfkrb9qE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Received:From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=LG/Bj3j+S/YFWEnFGmF91cNDmANqF1kDTd9q7KlTmuZyvoGiGgj3kBSEpE5f0E WwGxY5h87PAk8yVthWndC+uTlDf+SD1Eu8+gqF15S/1Kxw7/UGZS93IN4HRUd3S0 ak2uGuJugSEFE4uYI8b2CXchQYPoqjtNA9JCnYgLJj6XY=; Received: (qmail 10808 invoked by alias); 27 Jun 2012 09:53:20 -0000 Received: (qmail 10798 invoked by uid 22791); 27 Jun 2012 09:53:19 -0000 X-SWARE-Spam-Status: No, hits=-5.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, SPF_HELO_PASS, TW_ZJ, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 27 Jun 2012 09:53:04 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5R9r3ms005785 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 27 Jun 2012 05:53:03 -0400 Received: from freie (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q5R9r0PQ005893 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 27 Jun 2012 05:53:03 -0400 Received: from livre.localdomain (livre-to-gw.oliva.athome.lsd.ic.unicamp.br [172.31.160.19]) by freie (8.14.5/8.14.5) with ESMTP id q5R9qwUG024698; Wed, 27 Jun 2012 06:52:59 -0300 Received: from livre.localdomain (aoliva@localhost.localdomain [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id q5R9qvBX013045; Wed, 27 Jun 2012 06:52:57 -0300 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id q5R9quB4013043; Wed, 27 Jun 2012 06:52:56 -0300 From: Alexandre Oliva To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org, Jakub Jelinek , Richard Guenther Subject: Re: [PATCH] Fix accesses to freed up memory in var-tracking (PR debug/53706) References: Date: Wed, 27 Jun 2012 06:52:55 -0300 In-Reply-To: (Uros Bizjak's message of "Thu, 21 Jun 2012 11:32:35 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 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 On Jun 21, 2012, Uros Bizjak wrote: > Hello! >> > During htab_delete (dropped_values), loc_exp_dep_pool >> > allocated objects might be accessed, so it is better to free the >> > pool afterwards. >> > >> > Bootstrapped/regtested on i686-linux, ok for trunk? >> >> Looks obvious. > The patch doesn't fix all writes to freed up memory, please see > comment #8 in the PR audit trail. So, I've tested your patch in comment #10 on ia64-linux-gnu, and it worked, but it failed on i686- and x86_64-linux-gnu, just because in some cases we decided not to go through vt_emit_notes(), so loc_exp_dep_pool remained uninitialized, and free_alloc_pool doesn't like to release NULL pools ;-) The resulting patch was regstrapped on i686- and x86_64-linux-gnu. I'm going to check it in as obvious after getting some sleep. for gcc/ChangeLog from Alexandre Oliva , Uros Bizjak , Jakub Jelinek PR debug/53706 PR debug/47624 * var-tracking.c (vt_emit_notes): Release loc_exp_dep_pool... (vt_finalize): ... here instead, if needed. Index: gcc/var-tracking.c =================================================================== --- gcc/var-tracking.c.orig 2012-06-27 02:25:13.903896343 -0300 +++ gcc/var-tracking.c 2012-06-27 03:22:25.000000000 -0300 @@ -9260,11 +9260,7 @@ vt_emit_notes (void) dataflow_set_destroy (&cur); if (MAY_HAVE_DEBUG_INSNS) - { - free_alloc_pool (loc_exp_dep_pool); - loc_exp_dep_pool = NULL; - htab_delete (dropped_values); - } + htab_delete (dropped_values); emit_notes = false; } @@ -9974,6 +9970,9 @@ vt_finalize (void) if (MAY_HAVE_DEBUG_INSNS) { + if (loc_exp_dep_pool) + free_alloc_pool (loc_exp_dep_pool); + loc_exp_dep_pool = NULL; free_alloc_pool (valvar_pool); VEC_free (rtx, heap, preserved_values); cselib_finish ();