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: Sun, 08 Jun 2008 14:31:39 +0200 Message-ID: <87prqscdlg.fsf@rho.meyering.net> References: <87fxryjv2n.fsf@rho.meyering.net> <87abi4fjnp.fsf@rho.meyering.net> <20080608105325.GB42765@orion.lan> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1212928316 10636 80.91.229.12 (8 Jun 2008 12:31:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 8 Jun 2008 12:31:56 +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 Sun Jun 08 14:32:39 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 1K5K4b-00030N-Ua for ged-emacs-devel@m.gmane.org; Sun, 08 Jun 2008 14:32:38 +0200 Original-Received: from localhost ([127.0.0.1]:58317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K5K3o-00022u-RM for ged-emacs-devel@m.gmane.org; Sun, 08 Jun 2008 08:31:48 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K5K3i-00020v-Qx for emacs-devel@gnu.org; Sun, 08 Jun 2008 08:31:43 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K5K3h-0001zm-VD for emacs-devel@gnu.org; Sun, 08 Jun 2008 08:31:42 -0400 Original-Received: from [199.232.76.173] (port=35619 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K5K3h-0001zV-NQ for emacs-devel@gnu.org; Sun, 08 Jun 2008 08:31:41 -0400 Original-Received: from smtp3-g19.free.fr ([212.27.42.29]:49632) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1K5K3h-00012g-Ao for emacs-devel@gnu.org; Sun, 08 Jun 2008 08:31:41 -0400 Original-Received: from smtp3-g19.free.fr (localhost.localdomain [127.0.0.1]) by smtp3-g19.free.fr (Postfix) with ESMTP id 8A3AF17B592 for ; Sun, 8 Jun 2008 14:31:40 +0200 (CEST) Original-Received: from mx.meyering.net (mx.meyering.net [82.230.74.64]) by smtp3-g19.free.fr (Postfix) with ESMTP id 71CDF17B58D for ; Sun, 8 Jun 2008 14:31:40 +0200 (CEST) Original-Received: by rho.meyering.net (Acme Bit-Twister, from userid 1000) id 14B0238158; Sun, 8 Jun 2008 14:31:40 +0200 (CEST) In-Reply-To: <20080608105325.GB42765@orion.lan> (Emanuele Giaquinta's message of "Sun, 8 Jun 2008 12:53:25 +0200") Original-Lines: 57 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:98690 Archived-At: 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. 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