delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/01/08/00:18:46

From: "Mark E." <snowball3 AT bigfoot DOT com>
To: djgpp-workers AT delorie DOT com
Date: Mon, 8 Jan 2001 00:16:00 -0500
MIME-Version: 1.0
Subject: Re: valloc and memalign draft
Message-ID: <3A5906C0.4802.38ACFF@localhost>
References: <3A55C132 DOT 12287 DOT 6F26E9 AT localhost>
In-reply-to: <Pine.SUN.3.91.1010107082143.21289C-100000@is>
X-mailer: Pegasus Mail for Win32 (v3.12c)
Reply-To: djgpp-workers AT delorie DOT com

> 
> On Fri, 5 Jan 2001, Mark E. wrote:
> 
> > +   /* Temporarily clear chunk-in-use bit so macros work correctly.  */
> > +   b1->size &= ~1;
> 
> Isn't this a bit dangerous?  Doesn't it leave the malloc chain in an 
> inconsistent state, for a small window of opportunities?  What if some 
> signal (i.e. exception) strikes between this line and where you restore 
> the bit, and the code run from the signal handler calls memalign?

I hadn't thought of that. Would adding '& ~1' to BEFSZ, ENDSZ, etc. work for 
you?

BTW, the code I posted didn't handle block->size == 0 correctly (sigh). I 
created a test program that would expose the slightest flaw and finally 
managed to fix it.  The upshot is please don't anyone use it with gcc yet.

Mark

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019