www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/02/13/13:15:08

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Message-ID: <3C6AAB24.48974C81@yahoo.com>
From: CBFalconer <cbfalconer AT yahoo DOT com>
Organization: Ched Research
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Malloc/free DJGPP code
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1020213162355 DOT 18549C-100000 AT is>
Lines: 82
Date: Wed, 13 Feb 2002 18:08:10 GMT
NNTP-Posting-Host: 12.90.170.50
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc05-news.ops.worldnet.att.net 1013623690 12.90.170.50 (Wed, 13 Feb 2002 18:08:10 GMT)
NNTP-Posting-Date: Wed, 13 Feb 2002 18:08:10 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii wrote:
> 
> On Wed, 13 Feb 2002, DJ Delorie wrote:
> 
> > If you
> > really want to do this, call setbuf(stdout,0) at the beginning of your
> > program (stderr too) to avoid the need for a buffer.
> 
> And if unbuffered I/O is too slow, call setvbuf with a suitable buffer
> instead.  That should avoid the need to call malloc the first time printf
> is called.

Nope, that didn't do it.

[1] c:\c\hashlib>make hshtestp
*gcc -W -Wall -O2 -pg -gstabs+ -Dinline= -c malloc.c
gcc -pg -o hshtestp.exe hashtest.o cokusMT.o hashlib.o malloc.o

[1] c:\c\hashlib>timerun hshtestp 4
Timer 3 on: 12:43:05
Exiting due to signal SIGSEGV
General Protection Fault at eip=00004fca
eax=00004000 ebx=00004000 ecx=00000073 edx=0000ed44 esi=0000daf0
edi=00000000
ebp=0000dae8 esp=0000dad0 program=<??UNKNOWN??>
cs: sel=00af  base=84066000  limit=0023ffff
ds: sel=00b7  base=84066000  limit=0023ffff
es: sel=00b7  base=84066000  limit=0023ffff
fs: sel=0087  base=0000b600  limit=0000ffff
gs: sel=00c7  base=00000000  limit=0010ffff
ss: sel=00b7  base=84066000  limit=0023ffff
App stack: [00093550..00013550]  Exceptn stack:
[000134ac..0001156c]

Call frame traceback EIPs:
  0x00004fca
Timer 3 off: 12:43:06  Elapsed: 0:00:00.77

in hashtest.c

/* This is only for debugging the malloc mechanism system code */
#define DEBUG1 1
....
....
/* This is for debugging the malloc mechanism */
#if DEBUG1
   char iobuffer[1024];
#endif

/* Test the hash library system */
int main(int argc, char ** argv)
{
   int          t;
   unsigned int p;

/* This is for debugging the malloc mechanism ONLY */
#if DEBUG1
   /* Prevent printf's from calling malloc and self recursion */
   setvbuf(stdout, iobuffer, _IOLBF, sizeof iobuffer);
#endif
....

and the printfs in malloc are the original ones except that only a
subset is selected by DEBUG1 and the %08x spec replaced by %p

Seems pointless testing setvbuf return if printf blows it up. 
Next suggestion?

NOTE: linking to the normal malloc (without debuggery or -pgs)
works correctly.  And just to check that I really had recompiled
malloc:
> 
> [1] c:\c\hashlib>dir2 malloc.c;malloc.o /b
> malloc.c        12573   2-13-02  12:27  malloc.o         8129   2-13-02  12:42


-- 
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT XXXXworldnet DOT att DOT net)
   Available for consulting/temporary embedded and systems.
   (Remove "XXXX" from reply address. yahoo works unmodified)
   mailto:uce AT ftc DOT gov  (for spambots to harvest)

- Raw text -


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