Subject: Re: malloc.conf
To: Klaus Klein <kleink@mibh.de>
From: John Clark <jclark@metricsystems.com>
List: netbsd-users
Date: 07/13/2005 09:09:13
Klaus Klein wrote:
> On Fri, Jun 24, 2005 at 06:23:20PM +0100, Patrick Welche wrote:
>   
>> I'm trying to work out why GraphicsMagick is giving me things like
>>
>>    gm in free(): error: chunk is already free.
>>
>> and
>>
>>    gm in free(): error: freelist is destroyed.
>>
>> (also had a pthread warning) Anyway, I have
>>
>> % echo $MALLOC_OPTIONS
>> A
>> % ls -l /etc/malloc.conf
>> lrwxr-xr-x  1 root  wheel  1 Jun 24 18:00 /etc/malloc.conf -> A
>> %
>>
>> Yet I can't generate a coredump. Any idea what I have missed?
>>     
>
> Possibly the coredump size resource limit being too small (or
> disabling), either in the shell (ulimit -c) or as set by the process
> itself?
>   

While I can't speak for the specifics of GraphicsMagick and how it 
mallocs and frees, but
in my own pthread application, I got this error message due to a piece 
of bad code. There
was a 'malloc' inside a conditional. Then there was a 'free' outside the 
conditional. Obviously
if the condition was not satisfied, the free was using a stale or bogus 
pointer... yeah, obviously...
anyway, once I correctly placed the free inside the conditional were the 
pointer was guarenteed
to be valid, the error was gone.

It took some time to find this as gdb even on NetBSD's 'new' threads 
seems not to be working
really well. (Then there's gdb on linux with linuxThreads... which 
basically is unusable.)