From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20029 invoked by alias); 26 Feb 2018 20:24:59 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42404 Received: (qmail 29735 invoked by uid 1010); 26 Feb 2018 20:24:59 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-1.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(80.0.253.65):SA:0(-1.9/5.0):. Processed in 8.169227 secs); 26 Feb 2018 20:24:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Originating-IP: [86.21.219.59] X-Authenticated-User: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.3 cv=Q+n8Hb+a c=1 sm=1 tr=0 a=utowdAHh8RITBM/6U1BPxA==:117 a=utowdAHh8RITBM/6U1BPxA==:17 a=kj9zAlcOel0A:10 a=x7bEGLp0ZPQA:10 a=pGLkceISAAAA:8 a=yG5GxTSfatJcMrNbcRgA:9 a=CjuIK1q_8ugA:10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1519676686; bh=p4nw9Vob3LJ/eEWvye/L2Up2CISKv1IMcX3iXbdKIik=; h=Date:From:To:Subject:In-Reply-To:References; b=4RUWZ0qL/a42Y++D9SHPP08gJTA/6xXE5xzBptk1j/S0C+Xhhtvw9r+nz+Tsdwvj/ YWNwzMve7C4uIbmvg9YBDVqRDZPYdZe3X9nVM7QJOE1mfXbTRZBjBe8NGdKF2/E+05 X/AY8R6jtfQdK5lOcHatpXDzhR2ZvU3pLC77SwTrkbVbiL2XYTfbCnSjlV5w+2dTfn 9EsChy6QjGNhOjxd1nj7rTtEOx3+ylPlUgqLWDXxOrIQjAXA3NH0VsEy4myvhFI7iF abbDeiZjKGB2l2XEselkCU3FRvI8KU9t8lSIN3n4cVJMSNrjV2S/SZEwFlbfhAGKIy 9AC5kjsSHdYiA== Date: Mon, 26 Feb 2018 20:24:46 +0000 From: Peter Stephenson To: zsh workers Subject: Re: crash/hang with gcc 5+ -O2 and --enable-zsh-mem Message-ID: <20180226202446.08f467c8@ntlworld.com> In-Reply-To: <20180225070637.2weeeu63fhm4ebqk@gmail.com> References: <20180225001334.fzsdcy67cnosvj5z@gmail.com> <20180225070637.2weeeu63fhm4ebqk@gmail.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfL90ZImgQaY4spkKs/KBihfW3u7Jw+/OLm8306R2se4vz+/nqyUEnSwzCkI+ADuJFkOvcJO6GpAPti30XnJkHeFxWsvwZFA8B0a+Fr/JuEF9fKTHHDBB I5nRFi4FrUVCmLihx9jKjGBaIjNGHQO6jb7NPkES8U1HvFfO+QF0wp0VheiLpvifSHSPVTHA8A5BIg== On Sat, 24 Feb 2018 21:06:37 -1000 Joey Pabalinas wrote: > diff --git a/Src/mem.c b/Src/mem.c > index 840bbb6e4a4eb6fd73..f1208197b3ddac2139 100644 > --- a/Src/mem.c > +++ b/Src/mem.c > @@ -1719,7 +1719,13 @@ calloc(MALLOC_ARG_T n, MALLOC_ARG_T size) > if (!(l = n * size)) > return (MALLOC_RET_T) m_high; > > - r = malloc(l); > + /* > + * use realloc() (with a NULL `p` argument it behaves exactly the same > + * as malloc() does) to prevent an infinite loop caused by sibling-call > + * optimizations (the malloc() call would otherwise be replaced by an > + * unconditional branch back to line 1719 ad infinitum). > + */ > + r = realloc(NULL, l); > > memset(r, 0, l); Was going to object some older realloc()s don't support that behaviour, but this is quite specifically in zsh memory management where realloc() is explicitly defined, duh. Can't see a problem with this apart from a minor performance hit. calloc isn't used anywhere this would be a big deal, I don't think. I committed it, thanks. I suppose gcc really wants looking at too... pws