This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Malloc debug upsets alignment
- From: Dave Lawrence <dlawrence at ad-holdings dot co dot uk>
- To: ecos-discuss at sources dot redhat dot com
- Date: Tue, 03 Feb 2009 11:20:38 +0000
- Subject: [ECOS] Malloc debug upsets alignment
Hi
If CYGDBG_MEMALLOC_MALLOC_DEBUG_GUARDS is set then an 8 byte offset is
added to the start of the buffer. Therefore if
CYGNUM_MEMALLOC_ALLOCATOR_DLMALLOC_ALIGNMENT is > 3 the returned pointer
is guaranteed to not be aligned the way you expect it.
eg if the alignment specified is 6, one expects that (ptr % 64 == 0)
whereas the actual truth is that ((ptr - 8) % 64 == 0). ["ptr" being the
return value of malloc, in this context]
Having an unexpected alignment can, amongst other things, reduce the
performance of DMA engines and defeat your cache coherency strategy.
I would like to fix this but don't have time at the moment - switching
the debug guards off is an acceptable work around for me.
If / when I get a fix I'll post again -- if / when somebody else fixes
this I would appreciate a post. Thanks!
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss