Date: Fri, 27 Jan 2017 12:19:16 -0500 From: Alexander Kabaev <kabaev@gmail.com> To: Don Lewis <truckman@FreeBSD.org> Cc: current@FreeBSD.org Subject: Re: malloc() call somehow calling the rtld malloc() implementaion Message-ID: <20170127121916.6d675d26@kan> In-Reply-To: <201701270831.v0R8VUsC018788@gw.catspoiler.org> References: <201701270831.v0R8VUsC018788@gw.catspoiler.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--Sig_/s/2HiUiKqwG4NbCMhT04syM Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Fri, 27 Jan 2017 00:31:30 -0800 (PST) Don Lewis <truckman@FreeBSD.org> wrote: > I've been attempting to get OpenOffice to build properly in a > clang400-import poudriere jail and have run into a mystery. The build > procedure creates a c++ executable "idlc", which is used to build > other stuff. The new operator has been overrriden to call a custom > memory allocator, which I have configured to call the system version > of malloc(). >=20 > At some point idlc crashes because it has allocated a 16 byte > structure and the compiler is using "movaps %xmm0,(%rax)" to > initialize it, which requires 16 byte alignment. Unfortunately this > structure is only 8 byte aligned, causing a bus error. This > shouldn't be happening because our system malloc() always seems to do > the proper alignment. It appears that intead of calling the version > of malloc() in libc, the simple version of malloc() built into rtld > is being called instead. >=20 > GNU gdb 6.1.1 [FreeBSD] > Copyright 2004 Free Software Foundation, Inc. > GDB is free software, covered by the GNU General Public License, and > you are welcome to change it and/or distribute copies of it under > certain conditions. Type "show copying" to see the conditions. > There is absolutely no warranty for GDB. Type "show warranty" for > details. This GDB was configured as "amd64-marcel-freebsd"... > (gdb) break main > Breakpoint 1 at 0x43b1f6: file idlcmain.cxx, line 34. > (gdb) run @/tmp/r > Starting > program: /wrkdirs/usr/ports/editors/openoffice-devel/work/aoo-4.2.0/main/= solver/420/unxfbsdx.pro/bin/idlc > @/tmp/r [New LWP 101304] [New Thread 802616000 (LWP 101304/idlc)] > [Switching to Thread 802616000 (LWP 101304/idlc)] >=20 > Breakpoint 1, main (argc=3D2, argv=3D0x7fffffffb278) at idlcmain.cxx:34 > 34 SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) > (gdb) break malloc > Breakpoint 2 at 0x8006a5f01: > file /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc.c, > line 163. (gdb) cont Continuing. > Trace 12474/1: "Min Prioriy for policy '2' =3D=3D '0' > " > Trace 12474/1: "Max Prioriy for policy '2' =3D=3D '103' > " > /wrkdirs/usr/ports/editors/openoffice-devel/work/aoo-4.2.0/main/solver/42= 0/unxfbsdx.pro/bin/idlc: > compiling 1 source files ... > Compiling: /wrkdirs/usr/ports/editors/openoffice-devel/work/aoo-4.2.0/mai= n/offapi/com/sun/star/i18n/KParseTokens.idl >=20 > Breakpoint 2, malloc (nbytes=3D343) > at /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc= .c:163 > 163 /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc.c: > No such file or directory. > in /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc.c > Current language: auto; currently minimal (gdb) cont > Continuing. >=20 > Breakpoint 2, malloc (nbytes=3D32) > at /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc= .c:163 > 163 > in /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc.c > (gdb) cont Continuing. > Trace 13112/2: "ChildStatusProc : starting > '/wrkdirs/usr/ports/editors/openoffice-devel/work/aoo-4.2.0/main/solver/4= 20/unxfbsdx.pro/bin/ucpp'" [New > Thread 802616500 (LWP 100249/idlc)] [Switching to Thread 802616500 > (LWP 100249/idlc)] >=20 > Breakpoint 2, malloc (nbytes=3D19) > at /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc= .c:163 > 163 > in /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc.c > (gdb) cont Continuing. >=20 > Breakpoint 2, malloc (nbytes=3D34) > at /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc= .c:163 > 163 > in /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc.c > (gdb) cont Continuing. >=20 > Breakpoint 2, malloc (nbytes=3D16) > at /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc= .c:163 > 163 > in /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc.c > (gdb) cont Continuing. >=20 > Breakpoint 2, malloc (nbytes=3D16) > at /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc= .c:163 > 163 > in /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc.c > (gdb) cont Continuing. >=20 > Breakpoint 2, malloc (nbytes=3D16) > at /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc= .c:163 > 163 > in /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc.c > (gdb) cont Continuing. >=20 > Breakpoint 2, malloc (nbytes=3D16) > at /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc= .c:163 > 163 > in /var/poudriere/jails/clang400amd64/usr/src/libexec/rtld-elf/malloc.c > (gdb) cont Continuing. > sizeof(AstExprValue)=3D16 >=20 > Program received signal SIGBUS, Bus error. > [Switching to Thread 802616000 (LWP 101304/idlc)] > 0x0000000000478cc2 in AstExpression::eval_bit_op (this=3D0x802633dc8,=20 > ek=3DEK_const) at astexpression.cxx:1001 > 1001 std::auto_ptr< AstExprValue > retval(new > AstExprValue()); >=20 >=20 > idlc is linked to libc.so: >=20 > /wrkdirs/usr/ports/editors/openoffice-devel/work/aoo-4.2.0/main/solver/42= 0/unxfbsdx.pro/bin/idlc: > libreg.so.3 > =3D> /wrkdirs/usr/ports/editors/openoffice-devel/work/aoo-4.2.0/main/solv= er/420/unxfbsdx.pro/lib/libreg.so.3 > (0x8008b9000) libuno_sal.so.3 > =3D> /wrkdirs/usr/ports/editors/openoffice-devel/work/aoo-4.2.0/main/solv= er/420/unxfbsdx.pro/lib/libuno_sal.so.3 > (0x800c00000) libuno_salhelpergcc3.so.3 > =3D> /wrkdirs/usr/ports/editors/openoffice-devel/work/aoo-4.2.0/main/solv= er/420/unxfbsdx.pro/lib/libuno_salhelpergcc3.so.3 > (0x801040000) libm.so.5 =3D> /lib/libm.so.5 (0x801244000) libc++.so.1 > =3D> /usr/lib/libc++.so.1 (0x80146e000) libcxxrt.so.1 > =3D> /lib/libcxxrt.so.1 (0x801735000) libgcc_s.so.1 > =3D> /lib/libgcc_s.so.1 (0x801953000) libthr.so.3 =3D> /lib/libthr.so.3 > (0x801b69000) libc.so.7 =3D> /lib/libc.so.7 (0x801d91000) libstore.so.3 > =3D> /wrkdirs/usr/ports/editors/openoffice-devel/work/aoo-4.2.0/main/solv= er/420/unxfbsdx.pro/lib/libstore.so.3 > (0x802152000) >=20 >=20 > If I create a simple test program that calls malloc() and set a > breakpoint in malloc(), the breakpoint gets set in the rtld version, > but the the libc version of malloc is what gets called. >=20 > What the heck is going on here, and how can I fix it? >=20 rtld on my system does not have malloc exposed as dynamic symbol, it cannot possibly be used for symbol resolution by any outside module. --=20 Alexander Kabaev --Sig_/s/2HiUiKqwG4NbCMhT04syM Content-Type: application/pgp-signature Content-Description: Цифровая подпись OpenPGP -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEExffZlZm2QeE8UVaRBxMimZJ5Ln4FAliLgRRfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEM1 RjdEOTk1OTlCNjQxRTEzQzUxNTY5MTA3MTMyMjk5OTI3OTJFN0UACgkQBxMimZJ5 Ln5AOQ//UMSXfNLDi8eoN4/ck0uX2aD0o906HNLkK+XUMuroY21DZTA2nVmvdM7W BAuVQ8VRT80qjLqU2huWXTz11urqpOeEAY3nzNMn1nkAgT27oD9LPRleSZnZCKbS N7JHgME8e/E98LMuQQogEK6ixksYLN3PP5SLbm5aN5ysXRI+BiDt7MXp132V3pju hguDzBpN31aNrgwgycC8tiGlMQvxpD1f/If+Kvw6N8Zf9JRwJ7mWN/sgx8uMO//H RmoKT1YpeVuDmKi1Aa5IMBoLksdR0xmJGQaPLp+rdnLvz4W1Ut5jIrTvgGI0QzAw lSRSzPm+RFnemeFXbhMjcgNSAi0SjgbKCIqnW9AGznEzd4F6he1ondxSEP1DBgSK OYQDftIKcJKc2z/+qeJyqe2TnGzh8LzLY5qUBWHHEoIFsd0Al2JCfKmSM2tMgm4I IkIQNaSFGlFzuBAGoRyBoCk+gnVj8TngRNs6aWJopucMRmjQFZ7Ll/KccuWHo5hN EfydlaN1PiKt1DWp42m9oQMMwJdpLC75Ug5NnitOMuIunB9lrVyla3M69d3dBfXF umvUTiiqguHCr6BpeVV67tAszfG/P0YIsgs47UiHUjrwEmLVFPc/SWlGBiVYjL9v N9sBgmGO9fGFSVHsuOCZq9MIREjIrU6g7zz8Pf7scbcDg7CGnI8= =XbZz -----END PGP SIGNATURE----- --Sig_/s/2HiUiKqwG4NbCMhT04syM--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20170127121916.6d675d26>