Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Jul 2008 17:36:35 -0700
From:      Doug Hardie <bc979@lafn.org>
To:        Kris Kennaway <kris@FreeBSD.org>
Cc:        freebsd-questions@FreeBSD.org
Subject:   Re: malloc options
Message-ID:  <B20991AB-6D2F-4E9E-BC68-2073EFE598AF@lafn.org>
In-Reply-To: <488BBCFD.1090309@FreeBSD.org>
References:  <EE1CF633-524E-4AE3-8224-685D71652F36@lafn.org> <488BBCFD.1090309@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On Jul 26, 2008, at 17:10, Kris Kennaway wrote:

> Doug Hardie wrote:
>> I have a program that has run correctly since FreeBSD 3.7.   
>> However, when upgrading the server to 7.0 I am encountering issues  
>> where values just seem to arbirtrarily change.  These values are  
>> all located in memory allocated by malloc.  Malloc was  
>> significantly changed with 7.0 and reading through the malloc man  
>> page there are a number of flags that can be set with /etc/ 
>> malloc.conf.  The default for that file is to not exist.  The man  
>> page does not indicate which settings are used in that situation.   
>> After reading through it I get the feeling that the default  
>> settings for D and M are 'dM'.  Hence, to return to the older  
>> malloc aproach to see if the problems go away I would need to set  
>> "Dm".  But some of the descriptions seem to indicate that might not  
>> be correct.  What are the default settings?
>
> I don't think those are the right questions to be asking.

I fail to see why asking what the defaults are in not a valid  
question.  That information should be documented in the man page (or  
at least the developer's manual).  Dredging through malloc.c it  
appears that the defaults are actually DM.  If so, that gives me 2  
different options to try to see if the behavior changes (dM and Dm).   
Since those options affect the location of the data in the process  
address space its possible that one of them might come closer than DM  
to how malloc used to work.  It might give a temporary workaround till  
the underlying issue can get resolved.

>
>
> Firstly, if you did not recompile the program under 7.0 then it is  
> not using the new malloc at all.

It was recompiled.  All there is on the system is new stuff.  It was  
built from scratch when 7.0 came out.

>
>
> If you did recompile it and it is behaving differently then it is  
> probably because your program contains bugs in how it manages memory  
> that happened to be working by accident with the old memory  
> allocator. e.g. because you were making use of memory after it had  
> been freed, but before the allocator returned it to some other  
> malloc() call.

That is certainly possible.  However, the program has worked under  
considerable load for many years with versions 3.7 to 6.2.  Problems  
only occur with 7.0.  The program is quite complex and big.  It uses  
probably hundreds of mallocs in a typical use.  The problems only  
occur reasonably randomly and only under quite heavy load.  The  
developer is looking into it, but the problem only occurs on FreeBSD  
7.0, not any other Unix systems.  In the meantime I am losing money  
because of it.
>
>
> Finally, there is no way to revert to the "old approach" because the  
> new allocator is completely new; it allocates memory based on its  
> own strategy.  None of the malloc options affect the behaviour of  
> correct programs (but some of them can help to improve performance,  
> or to debug incorrect programs).

Not surprising but I seem to recall that when it was first introduced  
into stable that there was some discussion on how to make it look more  
like the old malloc.  I couldn't find that via a search though.

>
>
> Kris
>




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B20991AB-6D2F-4E9E-BC68-2073EFE598AF>