From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74960 invoked by alias); 16 Oct 2017 18:37:41 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 74950 invoked by uid 89); 16 Oct 2017 18:37:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Oct 2017 18:37:39 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id v9GIbXwW000877 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 16 Oct 2017 14:37:37 -0400 Received: by simark.ca (Postfix, from userid 112) id 156761E541; Mon, 16 Oct 2017 14:37:33 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id DE7C01E055; Mon, 16 Oct 2017 14:37:19 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 16 Oct 2017 18:37:00 -0000 From: Simon Marchi To: Yao Qi Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [RFA 4/8] Make strip_bg_char return a unique_xmalloc_ptr In-Reply-To: <86shejwi6t.fsf@gmail.com> References: <20171013205950.22943-1-tom@tromey.com> <20171013205950.22943-5-tom@tromey.com> <86shejwi6t.fsf@gmail.com> Message-ID: <88e7166cfba4e631a91a6a34d864d354@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 16 Oct 2017 18:37:33 +0000 X-IsSubscribed: yes X-SW-Source: 2017-10/txt/msg00458.txt.bz2 On 2017-10-16 05:33, Yao Qi wrote: > Tom Tromey writes: > >> - args = strip_bg_char (args, &async_exec); >> - args_chain = make_cleanup (xfree, args); >> + gdb::unique_xmalloc_ptr stripped = strip_bg_char (args, >> &async_exec); >> + args = stripped.get (); >> >> /* Do validation and preparation before possibly changing anything >> in the inferior. */ >> @@ -663,9 +663,6 @@ run_command_1 (char *args, int from_tty, enum >> run_how run_how) >> uiout->flush (); >> } >> >> - /* Done with ARGS. */ >> - do_cleanups (args_chain); >> - > > My concern is that we may leak something if some cleanups are > registered > to the cleanup chain in the callees between make_cleanup and > do_cleanups > here. However, I am not sure how to detect that. When reviewing previous cleanup-removal patches, I tried to look for something that hinted like it would install and return a cleanup, but it's obviously not a 100% reliable method. What you could do is temporarily add struct cleanup *before = cleanup_chain; at the beginning of the function, and gdb_assert (cleanup_chain == before); at the end. Simon