memcpy(): alignment error

Adam Lackorzynski adam at os.inf.tu-dresden.de
Tue Oct 21 23:31:35 CEST 2014


Hi,

On Mon Oct 20, 2014 at 20:32:20 +0200, ba_f wrote:
> Am 2014-10-19 23:48, schrieb Adam Lackorzynski:
> >
> >The alignment fault address is different (80006ece) from those mentioned
> >in the memcpy (0x80006e80-0x80006e88). Are you sure it is the memcpy?
> >
> >Adam
> 
> I do printf()-debugging.
> 
> #define STORE32N(buffer,offset,value)   { printf("memcpy(%x, %x,
> 4);\n",&buffer[offset], &value); memcpy(&buffer[offset], &value, 4);
> printf("No error, yet???\n");}
> 
> 
> And output is the following:
> 
> client  | memcpy(80004e8e, 80004e3c, 4);
> KERNEL0: alignment error at 80004e8e (PC: 00077a00, SP: 80004ac0, FSR:
> 410801, PSR: 60000010)
> client  | No signal handler found
> 
> printf("No error, yet???\n") is not reached. Client is broken, then.

Ok, so there's an unaligned address for the destination. Maybe you're
running into something like this:
http://stackoverflow.com/questions/24883410/armcc-problems-with-memcpy-alignment-exceptions
Assuming your buffer array is properly aligned on the stack, its data
type size seems to be != 4 (smaller?), why copy 4 bytes there?
And, why not just buffer[offset] = value? I'm sure the compiler would
do it just right.

> Is there something special to consider, since running an l4re-App?
> Something like request_mem(), or editing a configuration file?

No, it just has to work. You could switch off alignment checking in the
Fiasco config to allow such unaligned accesses. Still, with the checking
on, such alignment issues should not happen.



Adam
-- 
Adam                 adam at os.inf.tu-dresden.de
  Lackorzynski         http://os.inf.tu-dresden.de/~adam/




More information about the l4-hackers mailing list