[uClibc]Problems with realloc()?

Randy Sartin randys at ridgerun.com
Fri May 25 20:41:19 UTC 2001


I'm using a slightly older version (maybe a month old) of uClibc, but
the malloc code hasn't changed
since then...

I'm having problems with realloc() (in busybox insmod) not copying the
contents of the old buffer into
the new buffer. I (believe) that I've tracked it down to the way memory
management is handled between
the ARM uClinux 2.0.38.1pre7 kernel and uClibc.

in the file uClibc/stdlib/malloc/malloc.c:

Both realloc() and __hunk_free() get the HUNK start address by running
the PAGE_DOWNALIGNP(p)
macro. Then they check (h->id) for a HUNK_ID. The PAGE_DOWNALIGNP(p)
macro returns a page
aligned pointer. The problem is that on th ARM uClinux 2.0.38.1pre7
kernel, mmap returns hunk address
values on the page aligned boundary plus 0x18. If this occurs:

1) realloc() (since there isn't a valid HUNK_ID) will not copy old
contents to the new memory area
2) __heap_free() will not free the memory.

I've added an offset to "fix" this problem - but I don't understand the
memory manager enough to know
if I've really fixed the problem. There are also other places that
PAGE_DOWNALIGNP(p) is used,
and I wasn't sure what was going on in those routines.

Anyone have any better idea on how to fix this?

--
Randy Sartin
mailto:randys at ridgerun.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: randys.vcf
Type: text/x-vcard
Size: 332 bytes
Desc: Card for Randy Sartin
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20010525/c75869ee/attachment.vcf 


More information about the uClibc mailing list