Bug#215448: di_mem_chunk_alloc() should return sizeof(long) or better alignment
package: libdebian-installer
version: cvs
tags: d-i
di_mem_chunk_alloc() returns 4 byte aligned areas, even on 64 bit
platforms. This is bad, when the caller is going to lay some struct
containing longs or pointers over the alloc-ed memory. On ia64 it
results in loads of unaligned access exceptions flooding dmesg.
Alloc-ed memory comes from the mem[] array in the following struct
(from src/mem.c):
struct di_mem_area
{
di_mem_area *next; /**< the next mem area */
di_mem_area *prev; /**< the previous mem area */
di_ksize_t index; /**< the current index into the "mem" array */
di_ksize_t free; /**< the number of free bytes in this mem area */
di_ksize_t allocated; /**< the number of atoms allocated from this area */
char mem[MEM_AREA_SIZE]; /**< the mem array from which atoms get allocated
* the actual size of this array is determined by
* the mem chunk "area_size". ANSI says that it
* must be declared to be the maximum size it
* can possibly be (even though the actual size
* may be less).
*/
};
given:
include/debian-installer/types.h:typedef uint32_t di_ksize_t
the above array comes out at 4 byte alignment.
We need to make mem[] aligned(MEM_ALIGN).
I also wonder about MEM_AREA_SIZE being hardwired at 4, although I
didn't dig in to the code far enough to see if it should be 8 on 64 bit
platforms.
Reply to: