Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Feb 2014 20:29:13 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Dimitry Andric <dim@FreeBSD.org>
Cc:        Thomas Mueller <tmueller@sysgo.com>, ports <freebsd-ports@freebsd.org>
Subject:   Re: net/avahi-app core dumps signal 11
Message-ID:  <20140201182913.GC24664@kib.kiev.ua>
In-Reply-To: <A0A23193-C604-49B0-B8DD-3604055240F5@FreeBSD.org>
References:  <1390354628.14798.7.camel@lenovo.toontown> <20140129115404.04922dd6@tmu.ulm.sysgo.com> <C2CC6802-DD1B-4BD2-BA65-A694011DEAFF@FreeBSD.org> <20140131144111.7a8544f1@tmu.ulm.sysgo.com> <20140131165044.0dcf979d@tmu.ulm.sysgo.com> <E172DDDE-F695-4863-ADD5-49CB69909F1D@FreeBSD.org> <A0A23193-C604-49B0-B8DD-3604055240F5@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--jcjv6D8puUawUjle
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Jan 31, 2014 at 10:57:05PM +0100, Dimitry Andric wrote:
> On 31 Jan 2014, at 21:35, Dimitry Andric <dim@FreeBSD.org> wrote:
> ...
> > Hmm, at least I can reproduce it, but the stack trace does not tell me =
that much:
> >=20
> > (gdb) run
> > Starting program: /usr/work/share/dim/ports/net/avahi-app/work/avahi-0.=
6.31/./avahi-utils/.libs/avahi-browse
> > [New LWP 101263]
> >=20
> > Program received signal SIGSEGV, Segmentation fault.
> > [Switching to LWP 101263]
> > _thr_cancel_enter (curthread=3D0x0) at /share/dim/src/freebsd/head-clan=
g34/lib/libthr/thread/thr_cancel.c:141
> > 141             curthread->cancel_point =3D 1;
> > (gdb) bt
> > #0  _thr_cancel_enter (curthread=3D0x0) at /share/dim/src/freebsd/head-=
clang34/lib/libthr/thread/thr_cancel.c:141
> > #1  0x280d0f2d in __open (path=3D<optimized out>, flags=3D<optimized ou=
t>)
> >    at /share/dim/src/freebsd/head-clang34/lib/libthr/thread/thr_syscall=
s.c:390
> > #2  0x280fef46 in __guard_setup () at /share/dim/src/freebsd/head-clang=
34/gnu/lib/libssp/../../../contrib/gcclibs/libssp/ssp.c:72
> > #3  0x280ff182 in ?? () from /lib/libssp.so.0
> > #4  0x280fe749 in _init () from /lib/libssp.so.0
> > #5  0x00000000 in ?? ()
> > (gdb) up
> > #1  0x280d0f2d in __open (path=3D<optimized out>, flags=3D<optimized ou=
t>)
> >    at /share/dim/src/freebsd/head-clang34/lib/libthr/thread/thr_syscall=
s.c:390
> > 390             _thr_cancel_enter(curthread);
> > (gdb) up
> > #2  0x280fef46 in __guard_setup () at /share/dim/src/freebsd/head-clang=
34/gnu/lib/libssp/../../../contrib/gcclibs/libssp/ssp.c:72
> > 72        fd =3D open ("/dev/urandom", O_RDONLY);
> >=20
> > E.g., __guard_setup() tries to get some random bytes from /dev/urandom
> > (probably for the stack canaries), libthr considers this to be a thread
> > cancellation point, but for some reason the current thread is zeroed
> > out?  I don't think this is ever supposed to happen... :-)
>=20
> So avahi-browse gets linked as follows (wrapped a little for clarity):=20
>=20
> cc -I.. "-DDEBUG_TRAP=3D__asm__(\"int \$3\")"
> -DDATABASE_FILE=3D\"/usr/local/lib/avahi/service-types.db\" -O2 -pipe
> -march=3Dcorei7 -g -fno-strict-aliasing -fstack-protector -std=3Dc99 -Wall
> -W -Wextra -pedantic -pipe -Wformat -Wold-style-definition
> -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations
> -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls
> -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith
> -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings
> -fdiagnostics-show-option -Wno-cast-qual -fno-strict-aliasing
> -o .libs/avahi-browse avahi_browse-avahi-browse.o avahi_browse-sigint.o
> avahi_browse-stdb.o -L/usr/local/lib
> ../avahi-client/.libs/libavahi-client.so /usr/local/lib/libdbus-1.so
> -lpthread
> /usr/work/share/dim/ports/net/avahi-app/work/avahi-0.6.31/avahi-common/.l=
ibs/libavahi-common.so
> ../avahi-common/.libs/libavahi-common.so /usr/local/lib/libgdbm.so -lssp
> /usr/local/lib/libintl.so -pthread -Wl,-rpath -Wl,/usr/local/lib
>=20
> This executable segfaults, and has the NEEDED libs in the following
> order:
>=20
> .libs/avahi-browse:
>         libavahi-client.so.3 =3D> /usr/local/lib/libavahi-client.so.3 (0x=
28076000)
>         libdbus-1.so.3 =3D> /usr/local/lib/libdbus-1.so.3 (0x28085000)
>         libthr.so.3 =3D> /lib/libthr.so.3 (0x280cf000)
>         libavahi-common.so.3 =3D> /usr/local/lib/libavahi-common.so.3 (0x=
280f1000)
>         libgdbm.so.4 =3D> /usr/local/lib/libgdbm.so.4 (0x280fc000)
>         libssp.so.0 =3D> /lib/libssp.so.0 (0x28106000)
>         libintl.so.9 =3D> /usr/local/lib/libintl.so.9 (0x28109000)
>         libc.so.7 =3D> /lib/libc.so.7 (0x28112000)
>=20
> When I remove the -lssp from the above linking command line, it is
> automatically induced anyway, but the executable then gets the following
> NEEDED libs order:
>=20
> .libs/avahi-browse:
>         libavahi-client.so.3 =3D> /usr/local/lib/libavahi-client.so.3 (0x=
28076000)
>         libdbus-1.so.3 =3D> /usr/local/lib/libdbus-1.so.3 (0x28085000)
>         libthr.so.3 =3D> /lib/libthr.so.3 (0x280cf000)
>         libavahi-common.so.3 =3D> /usr/local/lib/libavahi-common.so.3 (0x=
280f1000)
>         libgdbm.so.4 =3D> /usr/local/lib/libgdbm.so.4 (0x280fc000)
>         libintl.so.9 =3D> /usr/local/lib/libintl.so.9 (0x28106000)
>         libc.so.7 =3D> /lib/libc.so.7 (0x2810f000)
>         libssp.so.0 =3D> /lib/libssp.so.0 (0x28263000)
>=20
> E.g. libssp.so.0 is now located at the end of the list.  And _this_
> executable runs fine...!
>=20
> If anyone has a good explanation for this, I would be dying to know. :-)

This sounds as if libssp initializers were run before libthr was initialize=
d.
Indeed, open(2) must be interposed by libthr to provide the cancellation
point.

Recompile rtld with debugging symbols and debugging enabled, like this:
cd libexec/rtld-elf
make DEBUG_FLAGS=3D-g DEBUG=3D-DDEBUG
and run both binaries with the LD_DEBUG=3D1 env variable set, than compare.

--jcjv6D8puUawUjle
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (FreeBSD)

iQIcBAEBAgAGBQJS7Tz4AAoJEJDCuSvBvK1BUZgP/jSid4xwj/kILvoDt8k1/PNQ
GjnlCfQGDzJrgBtgjZnwTccPU5ezycqJMyu+XgqLcy6LfwC5giVn8Ffj2ZTMx5lo
lJ648QNgQQEyKvyvLU1JSQwHV7EHtjjbe76n4kafLDJuPk+fz5GxlMLiY2uGs+B2
me+SlXwCmHVg/WQIdmYSV7SwoPMQKEbXhGOi5lNaujgXAobkeyQEp6ajW6wS+KtH
Zk0ZfYxw494Gau3N26f0zcqj0P/MfshERe7DSskukDGaU3ukJRns0cm84e2AsFIQ
Bf5/wPqcmky/r2abTruyKR2DyXxdaLSl6kC498ymTxj9g1JZ2uBJkRzWPT41f/8B
7CDUSriisannSzizpvHQ0aptCSi+gecY+5owWUvVwgPrFNMHfxD9Ndv5i861v2TH
K7+KNi8/QaGOfD/qtiGgDV0D8RwFyRWtSPXapXvLCdoJEeTMR9Ex1tJKSvu/OwA3
yVE0AmBuVmBnJdCtEyY4mwz+e7Twp/o91EDpsRNCFDbG+Ij2pphC72EP5Zl8SZ+g
j3rUo86rqSDmMtwR+4O9TK9xR74UcaioLDDmRn0v3Yze28r5YUTIkKgqdKmzKQqQ
zEhZlsg/OmDNTG3dKDSj0RLIJbYZksmvW6SCtnCsHBUwDTsBHtTyhrcY1dH2yvpA
dt1zh4biKDs1uvudwNfG
=s+Kk
-----END PGP SIGNATURE-----

--jcjv6D8puUawUjle--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140201182913.GC24664>