zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: pws-21: Re: BUG: 3.1.5-pws-21: lfs
Date: Mon, 14 Jun 1999 18:36:24 +0200	[thread overview]
Message-ID: <9906141636.AA30981@ibmth.df.unipi.it> (raw)
In-Reply-To: "Geoff Wing"'s message of "14 Jun 1999 08:49:36 NFT." <slrn7m9gh0.r33.mason@coral.primenet.com.au>

Geoff Wing wrote:
> Peter Stephenson <pws@ibmth.df.unipi.it> 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 <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


  reply	other threads:[~1999-06-14 17:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-13 10:51 Geoff Wing
1999-06-14  8:08 ` Geoff Wing
1999-06-14  7:49   ` Peter Stephenson
1999-06-14  8:28     ` Geoff Wing
1999-06-14  8:49     ` Geoff Wing
1999-06-14 16:36       ` Peter Stephenson [this message]
1999-06-15  4:06         ` PATCH: pws-21: " Geoff Wing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9906141636.AA30981@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).