From: James Yonan Subject: Re: [Openvpn-devel] Core dump ("unaligned access") on OpenBSD3.5 (DS10 - Alpha arch) In-Reply-To: <200412161651.10322.csr@...331...> Message-ID: References: <200412161458.49238.csr@...331...> <200412161651.10322.csr@...331...> MIME-Version: 1.0 Sender: openvpn-devel-admin@lists.sourceforge.net Errors-To: openvpn-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Id: List-Post: List-Help: List-Subscribe: , List-Archive: Date: Thu Dec 16 22:35:00 2004 Content-Type: TEXT/PLAIN; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: Christian =?iso-8859-1?q?R=F8snes?= Cc: openvpn-devel@lists.sourceforge.net On Thu, 16 Dec 2004, Christian [iso-8859-1] R=F8snes wrote: > On Thursday 16 December 2004 15:56, James Yonan wrote: > > On Thu, 16 Dec 2004, Christian [iso-8859-1] R=F8snes wrote: > > > > > > I can connect each endpoint, but when I try to ping either endpoint of > > > the vpn tunnel, the OpenVPN server dumps core and dies: > > > > > > pid 17868 (openvpn): unaligned access: va=3D0x12012f82f pc=3D0x120023= 900 > > > ra=3D0x1200238f4 op=3Dldl > > > Bus error (core dumped) > > > > > > Using gdb, I find: > > > > > > # gdb /usr/local/sbin/openvpn openvpn.core > > > GNU gdb 4.16.1 > > > ... > > > This GDB was configured as "alpha-unknown-openbsd3.5"... > > > Core was generated by `openvpn'. > > > > > > > > > Program terminated with signal 10, Bus error. > > > #0 0x120023904 in mroute_extract_addr_from_packet > > > (src=3D0x1ffffb220, dest=3D0x1ffffb208, buf=3D0x1, tunnel_type=3D-202= 92) 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. The whole reason I use mem= cpy > > here in the first place is to prevent alignment faults on the legacy > > processors that have trouble with them. > > > > Now on the other hand if the compiler tried to optimize the memcpy into= a > > 32 bit move instruction, then there will be problems because ip is not > > aligned correctly for that. > > > > What assembly code is being generated for the memcpy? > > > > Try, just as a test, compiling without optimization, and see if it affe= cts > > the code generated for the memcpy. > > > > James >=20 > Yes, removing -O2 from CFLAGS, and recompiling fixed the core dump problem > when pinging (although I get no answer, but that is maybe something relat= ed > to my configuration). > Then, setting -02 and recompiling after that brought the core dump back > when pinging. >=20 > So, the optimization seems to cause this somehow. > I'll leave -O2 off for now. Building without optimization might be overkill. Try keeping -O2 on, but add -fno-builtin-memcpy to eliminate the inlining of memcpy. See also this bug report which looks like an exact match to what your are=20 seeing: http://gcc.gnu.org/ml/gcc-bugs/2000-03/msg00155.html It looks like it might be possible to work around the issue with the right= =20 intermediate casting in mroute.c. James