From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jim Meyering Newsgroups: gmane.emacs.devel Subject: Re: emacs' turn: remove useless if-before-free tests Date: Tue, 10 Jun 2008 12:25:32 +0200 Message-ID: <87ej751t9f.fsf@rho.meyering.net> References: <87fxryjv2n.fsf@rho.meyering.net> <87abi4fjnp.fsf@rho.meyering.net> <20080608105325.GB42765@orion.lan> <87prqscdlg.fsf@rho.meyering.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1213093739 21561 80.91.229.12 (10 Jun 2008 10:28:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 10 Jun 2008 10:28:59 +0000 (UTC) Cc: Stefan Monnier , Emacs development discussions To: Emanuele Giaquinta Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Jun 10 12:29:42 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1K616Z-0005k8-OU for ged-emacs-devel@m.gmane.org; Tue, 10 Jun 2008 12:29:32 +0200 Original-Received: from localhost ([127.0.0.1]:34746 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K615m-00036B-09 for ged-emacs-devel@m.gmane.org; Tue, 10 Jun 2008 06:28:42 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K612t-0002LD-GI for emacs-devel@gnu.org; Tue, 10 Jun 2008 06:25:44 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K612n-0002J0-QH for emacs-devel@gnu.org; Tue, 10 Jun 2008 06:25:39 -0400 Original-Received: from [199.232.76.173] (port=38816 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K612n-0002Ib-5e for emacs-devel@gnu.org; Tue, 10 Jun 2008 06:25:37 -0400 Original-Received: from smtp3-g19.free.fr ([212.27.42.29]:44150) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K612l-00045N-GE for emacs-devel@gnu.org; Tue, 10 Jun 2008 06:25:36 -0400 Original-Received: from smtp3-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp3-g19.free.fr (Postfix) with ESMTP id 3043817B54A for ; Tue, 10 Jun 2008 12:25:33 +0200 (CEST) Original-Received: from mx.meyering.net (mx.meyering.net [82.230.74.64]) by smtp3-g19.free.fr (Postfix) with ESMTP id 1A6F417B548 for ; Tue, 10 Jun 2008 12:25:33 +0200 (CEST) Original-Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id F0C545B5E6; Tue, 10 Jun 2008 12:25:32 +0200 (CEST) In-Reply-To: <87prqscdlg.fsf@rho.meyering.net> (Jim Meyering's message of "Sun, 08 Jun 2008 14:31:39 +0200") Original-Lines: 60 X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:98852 Archived-At: Jim Meyering wrote: > Emanuele Giaquinta wrote: >> On Mon, Jun 02, 2008 at 08:14:18AM +0200, Jim Meyering wrote: >> >>> Stefan Monnier wrote: >>> > Sounds like a good cleanup. >>> > Feel free to install it unless there's a strong objection. >>> >>> Thanks. I've committed those three change sets. >> >> This patch introduced a problem on os x, free on os x is redirected to >> unexmacosx.c:unexec_free, which does not support a NULL argument in an >> undumped emacs. The attached patch changes the problematic free call to >> xfree, as done a few lines below for another pointer. >> >> Emanuele >> >> diff --git a/src/lread.c b/src/lread.c >> index e5e77bc..3e0bd1f 100644 >> --- a/src/lread.c >> +++ b/src/lread.c >> @@ -1269,7 +1269,7 @@ Return t if the file exists and loads successfully. */) >> >> UNGCPRO; >> >> - free (saved_doc_string); >> + xfree (saved_doc_string); >> saved_doc_string = 0; >> saved_doc_string_size = 0; > > Thanks for catching and fixing that. > If using xfree (with its MALLOC_BLOCK_INPUT guard) is important there, > as it seems to be, then your patch also fixes a platform-independent > race condition bug. > > The following change is probably a good idea, too. > It makes unexec_free (NULL) a no-op, just like free (NULL) is: > > 2008-06-08 Jim Meyering > > make unexec_free handle NULL the same way free does > * unexmacosx.c (unexec_free): Ignore a NULL argument. If no one objects soon, I'll commit both our changes. > diff --git a/src/unexmacosx.c b/src/unexmacosx.c > index 4662260..57f70f8 100644 > --- a/src/unexmacosx.c > +++ b/src/unexmacosx.c > @@ -1318,6 +1318,8 @@ unexec_realloc (void *old_ptr, size_t new_size) > void > unexec_free (void *ptr) > { > + if (ptr == NULL) > + return; > if (in_dumped_exec) > { > if (!ptr_in_unexec_regions (ptr)) > -- > 1.5.6.rc1.23.g2f46