[comp.sys.next] Help with malloc

zimmer@calvin.stanford.edu (Andrew Zimmerman) (03/21/91)

    I have a program that runs just fine on a DEC3100 and a Sparc 1, but
doesn't run correctly on my NeXT.  It acts line the static buffer used
by strtok is being written over by another part of my code.  This leads
to two possibilities, one is that my code is broken on all of the machines,
but I haven't gotten bitten yet on the other platforms, or there is a bug
in the malloc on the NeXT.  I had read that there was some problem with
alloc and malloc on the NeXT (in an article on comp.sys.next).  Is there
any truth to a possible bug in malloc?  

I haven't used the malloc debug stuff yet, so if you have any helpful pointers
on that, I would appreciate that info also.

Oh, lets see.  The program is straight c code on a NeXTstation slab with
8 meg of memory running OS 2.0.

Since I need this ASAP, any help would be greatly appreciated.

Thanks,
Andrew
zimmer@calvin.stanford.edu

zimmer@calvin.stanford.edu (Andrew Zimmerman) (03/21/91)

    Doesn't it always happen this way?  I try the program on a bunch of
different machines, don't get anywhere, so I post a message.  Then in 5
minutes I find the problem with the code.  So, as far as I know, there
isn't any problem with malloc on the NeXT.  

BTW, although there is a strtok in the libraries on the NeXT, there doesn't
appear to be a man page for it.

Andrew
zimmer@calvin.stanford.edu

das15@cunixa.cc.columbia.edu (Douglas A Scott) (03/21/91)

In article <1991Mar21.010307.18749@neon.Stanford.EDU> zimmer@calvin.stanford.edu (Andrew Zimmerman) writes:
>
>    I have a program that runs just fine on a DEC3100 and a Sparc 1, but
>doesn't run correctly on my NeXT.  It acts line the static buffer used
>by strtok is being written over by another part of my code.  This leads
>to two possibilities, one is that my code is broken on all of the machines,
>but I haven't gotten bitten yet on the other platforms, or there is a bug
>in the malloc on the NeXT.  I had read that there was some problem with
>alloc and malloc on the NeXT (in an article on comp.sys.next).  Is there
>any truth to a possible bug in malloc?  

	I have had the same problems with a large program that compiles
	and runs on Suns, DECs and SPARCs without an error, but gives me
	no end of grief under 2.0 on the cube.  It ran great under 1.0a,
	though.  I have tried all the tricks: mallocing a minimum of 16,
	32, 64, etc bytes, etc.  The only way I could get it to work was
	to turn off all malloc_debugging altogether (I had been using
	malloc_debug(8) in the code).

	Compiling with -lMallocDebug and running the MallocDebug App allows
	you to examine the running code in detail for memory errors.  Maybe
	2.0 is just better at catching these things...

___________________________________________________________________________
Douglas Scott
zardoz!doug%woof.columbia.edu