From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12103 invoked by alias); 16 Sep 2011 20:48:36 -0000 Received: (qmail 12095 invoked by uid 22791); 16 Sep 2011 20:48:36 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Sep 2011 20:48:22 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 9DF22CB037B; Fri, 16 Sep 2011 22:48:23 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bb17BGNqKief; Fri, 16 Sep 2011 22:48:13 +0200 (CEST) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 38EE4CB01D4; Fri, 16 Sep 2011 22:48:13 +0200 (CEST) From: Eric Botcazou To: Alexandre Oliva Subject: Re: [Ada] fix potential memory corruption in annotated value cache Date: Fri, 16 Sep 2011 21:04:00 -0000 User-Agent: KMail/1.9.9 Cc: gcc-patches@gcc.gnu.org References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <201109162245.37684.ebotcazou@adacore.com> Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg00993.txt.bz2 > Some possible fixes I considered were: > > 1. inserting on entry (as is), allocating the cache entry right away, > and *always* filling it before returning > > 2. inserting on entry (as is), allocating the cache entry right away, > and releasing it before returning unless we're filling it in > > 3. not inserting on entry, and looking up again for insertion before > caching and returning, so as to get a fresh slot pointer > > I implemented 3., and considered splitting the logic of annotate_value() > into one function that manages caching and calls the other to perform > the computation, so as to simplify the implementation. This looks like the most straightforward solution indeed. > Here's the patch I've tested on i686-pc-linux-gnu and x86_64-linux-gnu. > Ok to install? Yes, modulo Jakub's remark and s/NULL/NULL_TREE for zeroing in.base.from. -- Eric Botcazou