From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30734 invoked by alias); 9 Feb 2004 22:42:56 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 30727 invoked from network); 9 Feb 2004 22:42:55 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 9 Feb 2004 22:42:55 -0000 Received: by localhost.redhat.com (Postfix, from userid 469) id D970D1A4484; Mon, 9 Feb 2004 17:39:19 -0500 (EST) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16424.3095.770087.850919@localhost.redhat.com> Date: Mon, 09 Feb 2004 22:42:00 -0000 To: Daniel Jacobowitz Cc: carlton@kealia.com, gdb-patches@sources.redhat.com Subject: Re: Avoid obstack_free in cp-namespace.c In-Reply-To: <20040209211010.GA25073@nevyn.them.org> References: <20040209211010.GA25073@nevyn.them.org> X-SW-Source: 2004-02/txt/msg00217.txt.bz2 Daniel Jacobowitz writes: > > [For the curious I've audited the remaining uses of obstack_free in GDB. > The ones in jv-lang.c and stabsread.c are suspicious but seem to be OK, and > the rest are fine except for this one - they release whole obstacks.] I already did this in my cleanups. For the curious, you might as well explain the whole story. The obstack_free function takes a pointer to where in the stack it must start the deletion from (much like the cleanup chains have a pointer to where to start the cleanups). The obstack_free's in jv-lang.c and stabsread.c are done after some local stuff is allocated to the obstack. Only the local stuff is deleted from the obstack. Of course this assumes that nothing between the obstack_alloc and the obstack_free allocates anything else on the same obstack. For this reason other files use temporary obstacks. Maybe jv-lang.c and stabsread.c could do the same. This one had the same assumption. Releasing the whole obstack is not safe per se. It is safe only under the condition that we know the obstacks memory is no longer needed. In GDB we blow away the obstacks only when we get rid of the whole objfile(s). elena