From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5208 invoked from network); 14 Jun 1999 17:05:21 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 14 Jun 1999 17:05:21 -0000 Received: (qmail 5709 invoked by alias); 14 Jun 1999 17:05:00 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6626 Received: (qmail 5701 invoked from network); 14 Jun 1999 17:04:59 -0000 Message-Id: <9906141636.AA30981@ibmth.df.unipi.it> To: zsh-workers@sunsite.auc.dk Subject: PATCH: pws-21: Re: BUG: 3.1.5-pws-21: lfs In-Reply-To: "Geoff Wing"'s message of "14 Jun 1999 08:49:36 NFT." Date: Mon, 14 Jun 1999 18:36:24 +0200 From: Peter Stephenson Geoff Wing wrote: > Peter Stephenson typed: > :Geoff Wing wrote: > :> :I get a near continuous spew out of: > :> : BUG: attempt to free storage at invalid address > > First time through malloc(): > (m = sbrk(4096)) @ mem.c:760 gives m = 0x53b24 Ahaahaaha. See if this works. It's probably got too many casts 'n' stuff but I wanted it to be not too unsafe. There are a few assumptions anyway, but this time it looks like we're stuck with turning a pointer into an integer. --- Src/mem.c.sbrk Wed Jun 9 16:18:04 1999 +++ Src/mem.c Mon Jun 14 18:30:34 1999 @@ -777,6 +777,7 @@ for (mp = NULL, m = m_free; m && m->len < size; mp = m, m = m->next); } if (!m) { + long nal; /* no matching free block was found, we have to request new memory from the system */ n = (size + M_HSIZE + M_ALLOC + m_pgsz - 1) & ~(m_pgsz - 1); @@ -785,6 +786,14 @@ DPUTS(1, "MEM: allocation error at sbrk."); unqueue_signals(); return NULL; + } + if ((nal = ((long)(char *)m) & (M_ALIGN-1))) { + if ((char *)sbrk(M_ALIGN - nal) == (char *)-1) { + DPUTS(1, "MEM: allocation error at sbrk."); + unqueue_signals(); + return NULL; + } + m = (struct m_hdr *) ((char *)m + (M_ALIGN - nal)); } /* set m_low, for the check in free() */ if (!m_low) -- Peter Stephenson Tel: +39 050 844536 WWW: http://www.ifh.de/~pws/ Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy