This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Doug Lea's malloc implementation?


Bart Veer wrote:
"Nikolay" == Nikolay V Pyatkov <npyatkov@usa.net> writes:

    Nikolay> I was debugging GoAhead web server on linux synthetic
    Nikolay> target. It was crashing in the middle of the first page
    Nikolay> transfer. I traced the problem to free() in the "Doug
    Nikolay> Lea's malloc implementation". The values to the free
    Nikolay> looks fine. At the top of the stack was allocation of 4
    Nikolay> bytes and free of the same 4 bytes. I could not get any
    Nikolay> useful information from the dbg. I removed -O2. The same
    Nikolay> result.

    Nikolay> But after selecting "Simple variable block
    Nikolay> implementation" instead of " Doug Lea's malloc
    Nikolay> implementation" and recompiling the kernel everything
    Nikolay> works just fine.

    Nikolay> Did anyone see any problems with this package or it is
    Nikolay> just my setup?
Make sure you are using recent-ish anoncvs. Some bugs were fixed a year and a bit ago.

The Doug Lea malloc implementation is known to be pretty solid, and is
further stress-tested by the various tests in the services/memalloc
package (especially malloc4). However if there is a bug somewhere in
the application, for example a double free on a region of memory, then
you may well see different behaviour from the different allocators.
Or similarly easily, running off the end of an allocated bit of memory. A double free would cause an obvious assert failure for the variable allocator (something like "Couldn't free!" in free() in malloc.cxx). dlmalloc would probably also assert, but maybe not in so obvious a way.

With one allocator such a bug might go unnoticed (assuming the freed
memory has not yet been reallocated), while with another allocator it
might cause immediate memory corruption. Make sure you are running
with CYGDBG_MEMALLOC_ALLOCATOR_DLMALLOC_DEBUG enabled, that may help find the problem.
Indeed. That should be on by default when asserts are enabled. And for development, asserts should always be enabled :).

Jifl
--
--[ "You can complain because roses have thorns, or you ]--
--[ can rejoice because thorns have roses." -Lincoln ]-- Opinions==mine


--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]