delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/07/17/11:30:21

From: Charles Sandmann <sandmann AT clio DOT rice DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: malloc/free blues - for Peter Claessens
Date: Thu, 17 Jul 2003 10:16:12 CDT
Organization: Rice University, Houston, TX
Lines: 21
Message-ID: <3f16bdbc.sandmann@clio.rice.edu>
References: <3F156434 DOT 3000508 AT psy DOT kuleuven DOT ac DOT be> <3F16A652 DOT 24B6FEA5 AT psy DOT kuleuven DOT ac DOT be> <08da01c34c6b$be890bd0$0600000a AT broadpark DOT no> <7458-Thu17Jul2003175053+0300-eliz AT elta DOT co DOT il>
NNTP-Posting-Host: clio.rice.edu
X-Trace: joe.rice.edu 1058455148 11710 128.42.105.3 (17 Jul 2003 15:19:08 GMT)
X-Complaints-To: abuse AT rice DOT edu
NNTP-Posting-Date: Thu, 17 Jul 2003 15:19:08 +0000 (UTC)
X-NewsEditor: ED-1.5.9
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

> > From: "Gisle Vanem" <giva AT bgnett DOT no>
> > Date: Thu, 17 Jul 2003 16:00:13 +0200
> > 
> > #include <crt0.h>
> > int _crt0_startup_flags =  _CRT0_FLAG_FILL_SBRK_MEMORY |
> >                   _CRT0_FLAG_FILL_DEADBEEF;
> > 
> > in the main module.
> 
> I think this will only help if an uninitialized pointers are passed to
> `free'.  It is much more probable that the bug is in some code that
> writes past the end of an allocated buffer; in that case, I don't
> think the above will help (but it won't hurt to try that).

I agree he should set the deadbeef flag even if the problem is in free,
since this will make the behavior consistent between runs.  For example,
he might be passing an uninitialized value to free - and when you
see the deadbeef (or something close) - you know you've got a bug.

If the program fails in two different places when run twice, always
fill the memory.

- Raw text -


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