Date: Sat, 28 Jan 2017 09:53:49 +1100 From: Jan Mikkelsen <janm@transactionware.com> To: Don Lewis <truckman@FreeBSD.org> Cc: current@FreeBSD.org Subject: Re: malloc() call somehow calling the rtld malloc() implementaion Message-ID: <FF5FFDD1-FEDD-4876-872F-94D089C342E8@transactionware.com> 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
Hi, Are you being affected by this rtld behaviour: = https://lists.freebsd.org/pipermail/freebsd-hackers/2016-July/049769.html = <https://lists.freebsd.org/pipermail/freebsd-hackers/2016-July/049769.html= > https://lists.freebsd.org/pipermail/freebsd-stable/2015-July/082751.html = <https://lists.freebsd.org/pipermail/freebsd-stable/2015-July/082751.html>= (I still find this a bit scary.) Regards, Jan. > On 27 Jan 2017, at 19:31, Don Lewis <truckman@FreeBSD.org> wrote: >=20 > 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/420= /unxfbsdx.pro/bin/idlc: compiling 1 source files ...=20 > Compiling: = /wrkdirs/usr/ports/editors/openoffice-devel/work/aoo-4.2.0/main/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/42= 0/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/420= /unxfbsdx.pro/bin/idlc: > libreg.so.3 =3D> = /wrkdirs/usr/ports/editors/openoffice-devel/work/aoo-4.2.0/main/solver/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/solver/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/solver/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/solver/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 > _______________________________________________ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to = "freebsd-current-unsubscribe@freebsd.org"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?FF5FFDD1-FEDD-4876-872F-94D089C342E8>