* James Yonan:

>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>> Program terminated with signal 10, Bus error.
>> #0  0x120023904 in mroute_extract_addr_from_packet 
>> (src=0x1ffffb220, dest=0x1ffffb208, buf=0x1, tunnel_type=-20292) at 
>> mroute.c:113
>> 113                           memcpy (src->addr, &ip->saddr, 4);
>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>> 
>> I think my system choke on the 'ip->saddr' address in the memcpy statement.
>
> That's strange that it would hit an alignment fault on a memcpy.  memcpy
> is supposed to operate at byte granularity.

I suspect this statement is the problem:

  const struct openvpn_iphdr *ip = (const struct openvpn_iphdr *) BPTR (buf);

The cast results in undefined behavior if BPTR (buf) has the wrong
alignment.  Recent versions of GCC know this and therefore conclude
that BPTR must be properly aligned.  As a result, it is possible to
replace memcpy() with something that copies word-wise.

The char * casts in your other message won't fix this, they come too
late.  It's a common misconception that char pointers behave like
machine addresses.  They don't.

Just to be clear, this is not a bug in GCC.  Your code is not valid C.

Reply via email to