From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20559 invoked by alias); 25 Mar 2008 01:00:29 -0000 Received: (qmail 20523 invoked by uid 22791); 25 Mar 2008 01:00:13 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 25 Mar 2008 00:59:42 +0000 Received: from kahikatea.snap.net.nz (228.31.255.123.static.snap.net.nz [123.255.31.228]) by viper.snap.net.nz (Postfix) with ESMTP id 0F8B53DA2EE; Tue, 25 Mar 2008 13:59:35 +1300 (NZDT) Received: by kahikatea.snap.net.nz (Postfix, from userid 1000) id 736E48FC6D; Tue, 25 Mar 2008 12:59:26 +1200 (NZST) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18408.20077.725694.159007@kahikatea.snap.net.nz> Date: Tue, 25 Mar 2008 06:28:00 -0000 To: Vladimir Prus Cc: gdb@sources.redhat.com Subject: Re: Thread bound variable objects In-Reply-To: <200803240843.54604.vladimir@codesourcery.com> References: <200803190016.02072.vladimir@codesourcery.com> <200803231225.31593.vladimir@codesourcery.com> <18407.10216.545852.450467@kahikatea.snap.net.nz> <200803240843.54604.vladimir@codesourcery.com> X-Mailer: VM 7.19 under Emacs 22.1.92.2 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-03/txt/msg00213.txt.bz2 > > OK, it should be: > > > > + if (old_cleanups != NULL) > > + do_cleanups (old_cleanups); > > I think that's also wrong. In the event that no cleanups were installed > before calling this function, this code will fail to run the > cleanups installed by this function. In the event that a cleanup > should be really installed conditionally, the right code is: > > struct cleanups *back_to = make_cleanup (null_cleanup, NULL); > > if (...) > make_cleanup (); > > do_cleanups (back_to); OK, I hadn't realised that. I was looking at other files, e.g., dwarf2read.c which uses this technique. That appears to just be with xfree so maybe only results in a memory leak. I guess struct cleanups *old_cleanups = 0x1; ... if (old_cleanups != 0x1) do_cleanups (old_cleanups); would work but, as you say, it's probably best to use null_cleanup. -- Nick http://www.inet.net.nz/~nickrob