I've noticed something really strange.
say I've got the following structure defined
typedef struct
{
uint32_t a;
uint16_t b;
uint32_t c;
} foo;
This structure is contained in a big buffer I receive from network.
The following code works in x86, but I receive SIGBUS
on ARM.
extern void * buffer;
foo my_foo;
my_foo = (( foo * ) buffer)[0];
replacing the pointer dereferencing with memcpy solved the issue.
Searching about SIGBUS in ARM pointed me to the fact that this is related to memory alignment somwhow.
Can someone explain what's going on ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…