I do have with memcpy (depending on params) a warning/error: Alignment trap
I understand it like that, that pointers are not aligned. But in my special case it is strange, that are u8*. And, sometimes there are this messages, sometimes not. It seems that memcp itself works fine (so result seems to be ok). I can’t see a coincidence when it is ok and when not ?!?
u32 pictureCopy(u8 *to, u32 *from)
{
u32 expected_size;
u8 *source;
u8 *target;
u32 *counter;
u32 *size;
....
counter = from-2;
size = from-1;
source = (u8 *)from;
target = to;
for (int i=0; i<expected_size/2 ; i+= saved_image_setting2.width) {
printf("\n# i, target, source, size %i, %p, %p, %i\n", i, &target[i], &source[i], saved_image_setting2.width);
sleep(1);
memcpy(&target[i], &source[i], saved_image_setting2.width);
sleep(1);
printf("\nend %i\n", i);
}
Output is like that:
# i, target, source, size 0, 0xb500800a, 0xb5cf2008, 84
Alignment trap: sps (1493) PC=0xb6e1ced4 Instr=0x14913004 Address=0xb5cf2056 FSR 0x011
end 0
#i, target, source, size 84, 0xb500805e, 0xb5cf205c, 84
end 84
## i, target, source, size 168, 0xb50080b2, 0xb5cf20b0, 84
Alignment trap: sps (1493) PC=0xb6e1ced4 Instr=0x14913004 Address=0xb5cf20fe FSR 0x011
end 168
## i, target, source, size 252, 0xb5008106, 0xb5cf2104, 84
end 252
Looking at the pointers, first is always not a multiple of 4, but 2nd pointer is. Length is same! I don’t understand. What is problem and what differes between this lines.
Testing this with valgrind doesn’t give me a clue. valgrind --leak-check=yes
Hardware is a Zynq, dual core A9 ARM, OS is Yocto Linux – Arno Oct 25 '18 at 09:33