[gclist] Re: [m-dev.] memory leaks & Boehm collector
Nick Barnes
Nick.Barnes@pobox.com
Tue, 05 Oct 1999 10:59:14 +0100
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