avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] I thought I understood malloc


From: Steve Franks
Subject: Re: [avr-libc-dev] I thought I understood malloc
Date: Thu, 29 Mar 2007 08:59:35 -0700

On 3/29/07, Dave Hylands <address@hidden> wrote:

Hi Steve,

> 00803c18 D __malloc_heap_start
> 00803c1a D __malloc_heap_end

> I'm looking at the avrlibc docs right now, and they seem to indicate
that my
> makefile should be instructing both heap_end and malloc_heap_end to be
at
> 0x80A0FF.

Looking at the source code of avr-libc, it seems that _malloc_head_end
is a char * pointer that is initialized to &__heap_end.

So it's the contents of __malloc_heap_end not the address of
__malloc_heap_end that points to __heap_end.

Unfortunately, memory tramples are nasty bugs to find. They're often
caused by using functions such as strcpy, strcat, or sprintf and
providing buffers which are too small to hold the results.

This can occur on the stack or on the heap. Also check your stack to
make sure you're not getting stack overflow.

--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/


Well, last night I added:

override LDFLAGS        =
-Wl,--section-start,.data=0x802100,--defsym=__heap_end=0x80A0ff,,--defsym=__malloc_heap_end=0x80A0ff,--defsym=__malloc_heap_start=0x8080ff,-Map=$(PRG).map,--cref
-lm -u vfprintf -u vfscanf -lprintf_flt -lscanf_flt -lm -lc

And things look to be hunky-dory now.  Of course, I accept that this could
have just moved things around and covered the real bug up again, but I am
suspicious either way.

Steve


reply via email to

[Prev in Thread] Current Thread [Next in Thread]