[gclist] Re: [m-dev.] memory leaks & Boehm collector

Nick Barnes Nick.Barnes at pobox.com
Tue Oct 5 19:59:14 AEST 1999


At 1999-10-05 09:00:51+0000, Nick Barnes writes:
> At 1999-10-04 21:52:06+0000, Fergus Henderson writes:
> 
> > In fact the problem turned out to be one of those blindingly simple
> > stupid mistakes... in the above-mentioned code to zero out the Mercury
> > stacks, I had put the arguments to memset() in the wrong order :-(
> > Instead of setting a lot of bytes to zero, I set zero bytes.
> > Thus the Mercury stacks weren't being cleared at all, which
> > explained the leak.
> 
> Run, don't walk, to your Makefile and turn on some compiler warnings.
> Don't forget -Werror.

My apologies; I forgot how crap memset()s prototype is.  A properly
designed interface would of course have the middle argument be of type
"char", not "int", which would allow warning switches such as GCC's
(somewhat crap) -Wconversion to pick this up.  As it is, you would
have to use a fairly serious lint tool to detect something like this;
compiler warnings generally won't hack it.

A better approach is to avoid use of functions with such seriously
broken interfaces as memset().

Nick B

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list