Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Dec 2012 22:33:31 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Mark Atkinson <atkin901@gmail.com>
Cc:        freebsd-current@freebsd.org, kde-freebsd@spider.kde.org
Subject:   Re: problems with threads/destructors in -current with llvm/clang
Message-ID:  <20121210203331.GV3013@kib.kiev.ua>
In-Reply-To: <ka5gmu$129$1@ger.gmane.org>
References:  <k9qjml$ri7$1@ger.gmane.org> <50C1E81A.1040107@FreeBSD.org> <50C1F862.2010501@FreeBSD.org> <k9t6bq$bhs$1@ger.gmane.org> <50C22789.3030303@FreeBSD.org> <ka56gv$t60$1@ger.gmane.org> <20121210182525.GR3013@kib.kiev.ua> <ka5gmu$129$1@ger.gmane.org>

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

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

On Mon, Dec 10, 2012 at 12:29:20PM -0800, Mark Atkinson wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>=20
> On 12/10/2012 10:25, Konstantin Belousov wrote:
> > On Mon, Dec 10, 2012 at 09:35:29AM -0800, Mark Atkinson wrote: On
> > 12/07/2012 09:29, Dimitry Andric wrote:
> >>>> On 2012-12-07 17:43, Mark Atkinson wrote:
> >>>>> On 12/7/2012 6:08 AM, Dimitry Andric wrote:
> >>>> ...
> >>>>>> With this patch (placed in
> >>>>>> /usr/ports/devel/dbus-qt4/files), qdbus starts up and
> >>>>>> exits normally for me.  I did not do any other rigorous
> >>>>>> testing, though. :)
> >>>>>=20
> >>>>> Thanks for the awesome analysis.  I will endeavor to figure
> >>>>> out the bug in automoc4 that keeps it segfaulting randomly
> >>>>> during compilation.
> >>>>>=20
> >>>>> Weirdly it segfaults reliably under portmaster, but may
> >>>>> work just fine under just make.
> >>>>=20
> >>>> Try running it under valgrind.  If it does undefined things,
> >>>> it may work or not work randomly, and valgrind usually
> >>>> catches this.
> >=20
> > OK, so this one's a bit of a headscratcher, but maybe someone has
> > some ideas.  automoc4 always dies in libthr.
> >> Build rtld, libc and libthr with the debug symbols to get useful=20
> >> backtrace.
> >=20
> >=20
> > #0  0x2864b1da in swapcontext () from /lib/libthr.so.3 [New Thread
> > 29003800 (LWP 100960/automoc4.bin)] [New Thread 29003080 (LWP
> > 101795/automoc4.bin)] (gdb) bt #0  0x2864b1da in swapcontext ()
> > from /lib/libthr.so.3 #1  0x2864a046 in pthread_getspecific () from
> > /lib/libthr.so.3 #2  0x28649e9a in pthread_getspecific () from
> > /lib/libthr.so.3 #3  0x2864dbfb in pthread_kill () from
> > /lib/libthr.so.3 #4  0x28064e71 in _rtld_get_stack_prot () from
> > /libexec/ld-elf.so.1 #5  0x2865d500 in _thread_state_running ()
> > from /lib/libthr.so.3 #6  0x2865d500 in _thread_state_running ()
> > from /lib/libthr.so.3 #7  0x28075e00 in ?? () #8  0x286b4d30 in
> > pipe () from /lib/libc.so.7 #9  0x280712ac in ?? () from
> > /libexec/ld-elf.so.1 #10 0xbf9fce2c in ?? () #11 0x2805e505 in
> > r_debug_state () from /libexec/ld-elf.so.1 #12 0x28071f68 in ?? ()
> > from /libexec/ld-elf.so.1 #13 0xbf9fcde0 in ?? () #14 0xbf9fce18 in
> > ?? () #15 0x00000001 in ?? () #16 0x00000000 in ?? () (gdb) thread
> > 2 [Switching to thread 2 (Thread 29003080 (LWP
> > 101795/automoc4.bin))]#0 0x2876c3a7 in select () from
> > /lib/libc.so.7 (gdb) bt #0  0x2876c3a7 in select () from
> > /lib/libc.so.7 #1  0x286481ab in select () from /lib/libthr.so.3 #2
> > 0x28365c49 in qt_safe_select (nfds=3D17, fdread=3D0xbfbfa090,=20
> > fdwrite=3D0xbfbfa010, fdexcept=3D0x0, orig_timeout=3D0x0) at=20
> > kernel/qcore_unix.cpp:83 #3  0x282c23b2 in select_msecs (nfds=3D17,
> > fdread=3D0xbfbfa090, fdwrite=3D0xbfbfa010, timeout=3D-1) at
> > io/qprocess_unix.cpp:998 #4  0x282c33f3 in
> > QProcessPrivate::waitForFinished (this=3D0x29089300, msecs=3D-1) at
> > io/qprocess_unix.cpp:1219 #5  0x28240b50 in
> > QProcess::waitForFinished (this=3D0xbfbfa1e8, msecs=3D-1) at
> > io/qprocess.cpp:1759 #6  0x0805487b in AutoMoc::echoColor
> > (this=3D0xbfbfab00, msg=3D@0xbfbfa2e0) at=20
> > /usr/ports/devel/automoc4/work/automoc4-0.9.88/kde4automoc.cpp:74=20
> > #7  0x08052650 in AutoMoc::generateMoc (this=3D0xbfbfab00,=20
> > sourceFile=3D@0x29011658, mocFileName=3D@0x2901165c) at=20
> > /usr/ports/devel/automoc4/work/automoc4-0.9.88/kde4automoc.cpp:569=20
> > #8  0x0804f13b in AutoMoc::run (this=3D0xbfbfab00) at=20
> > /usr/ports/devel/automoc4/work/automoc4-0.9.88/kde4automoc.cpp:470=20
> > #9  0x0804aaef in main (argc=3D6, argv=3D0xbfbfab98) at=20
> > /usr/ports/devel/automoc4/work/automoc4-0.9.88/kde4automoc.cpp:114
> >=20
> > I noticed that qt_safe_select() used a register bound variable for
> > the return value, but removing that didn't alleviate the error.
> >=20
> > The pthread_getspecific() manpage mentions that if the key is
> > deleted then the behavior is undefined -- so maybe this?  It's
> > definitely seems like a race condition of some kind.
> >=20
> > Valgrind will kill any run of automoc4 and doesn't like some=20
> > instruction after the qt_safe_select() call:
> >=20
> > vex x86->IR: unhandled instruction bytes: 0xF 0xB 0x90 0x90
> >> This is ud2, an instruction which generates a fault on purpose.
> >=20
> >> So rebuild the system libraries with the debug symbols and show=20
> >> the backtrace.
>=20
> Hmm.  Since I took out -O2 and added -g in rebuilding
> libthr/libc/rtld, I figured I needed to reproduce a new segfault, but
> the rtld side of things seems broken:
Use e.g.
cd src/libexec/rtld-elf && make DEBUG_FLAGS=3D-g clean all install
This is really FAQ.

>=20
> #0  0xbf9fd01a in ?? ()
> [New Thread 29003800 (LWP 100652/automoc4.bin)]
> [New Thread 29003080 (LWP 101395/automoc4.bin)]
> (gdb) bt
> #0  0xbf9fd01a in ?? ()
> #1  0xbf9fcd20 in ?? ()
> #2  0x00000000 in ?? ()
> (gdb) info thread
>   2 Thread 29003080 (LWP 101395/automoc4.bin)  select () at select.S:3
> * 1 Thread 29003800 (LWP 100652/automoc4.bin)  0xbf9fd01a in ?? ()
> Current language:  auto; currently asm
> (gdb) thread 2
> [Switching to thread 2 (Thread 29003080 (LWP 101395/automoc4.bin))]#0
>  select () at select.S:3
> 3       RSYSCALL(select)
> (gdb) bt
> #0  select () at select.S:3
> #1  0x28659028 in __select (numfds=3D17, readfds=3D0xbfbfc1f0,
> writefds=3D0xbfbfc170, exceptfds=3D0x0, timeout=3D0x0) at
> /usr/src/lib/libthr/thread/thr_syscalls.c:539
> #2  0x28372c49 in qt_safe_select (nfds=3D17, fdread=3D0xbfbfc1f0,
> fdwrite=3D0xbfbfc170, fdexcept=3D0x0, orig_timeout=3D0x0) at
> kernel/qcore_unix.cpp:83
> #3  0x282cf3b2 in select_msecs (nfds=3D17, fdread=3D0xbfbfc1f0,
> fdwrite=3D0xbfbfc170, timeout=3D-1) at io/qprocess_unix.cpp:998
> #4  0x282d03f3 in QProcessPrivate::waitForFinished (this=3D0x29089300,
> msecs=3D-1) at io/qprocess_unix.cpp:1219
> #5  0x2824db50 in QProcess::waitForFinished (this=3D0xbfbfc348,
> msecs=3D-1) at io/qprocess.cpp:1759
> #6  0x0805487b in AutoMoc::echoColor (this=3D0xbfbfcc60,
> msg=3D@0xbfbfc440) at
> /usr/ports/devel/automoc4/work/automoc4-0.9.88/kde4automoc.cpp:74
> #7  0x08052650 in AutoMoc::generateMoc (this=3D0xbfbfcc60,
> sourceFile=3D@0x29011638, mocFileName=3D@0x2901163c) at
> /usr/ports/devel/automoc4/work/automoc4-0.9.88/kde4automoc.cpp:569
> #8  0x0804f13b in AutoMoc::run (this=3D0xbfbfcc60) at
> /usr/ports/devel/automoc4/work/automoc4-0.9.88/kde4automoc.cpp:470
> #9  0x0804aaef in main (argc=3D6, argv=3D0xbfbfccfc) at
> /usr/ports/devel/automoc4/work/automoc4-0.9.88/kde4automoc.cpp:114
> (gdb) thread 1
> [Switching to thread 1 (Thread 29003800 (LWP 100652/automoc4.bin))]#0
>  0xbf9fd01a in ?? ()
> (gdb) bt
> #0  0xbf9fd01a in ?? ()
> #1  0xbf9fcd20 in ?? ()
> #2  0x00000000 in ?? ()
> (gdb) frame 0
> #0  0xbf9fd01a in ?? ()
> (gdb) info reg
> eax            0x0      0
> ecx            0x286d7ddb       678264283
> edx            0x0      0
> ebx            0xbf9fd058       -1080045480
> esp            0xbf9fcd1c       0xbf9fcd1c
> ebp            0x14     0x14
> esi            0x2865c563       677758307
> edi            0x2869f2ec       678032108
> eip            0xbf9fd01a       0xbf9fd01a
> eflags         0x210246 2163270
> cs             0x33     51
> ss             0x3b     59
> ds             0x3b     59
> es             0x3b     59
> fs             0x3b     59
> gs             0x1b     27
>=20
>=20
> > =3D=3D33074=3D=3D valgrind: Unrecognised instruction at address
> > 0x380434e9. =3D=3D33074=3D=3D    at 0x380434E9: ??? (in=20
> > /usr/local/lib/valgrind/memcheck-x86-freebsd) =3D=3D33074=3D=3D    by
> > 0x323C48: qt_safe_select(int, fd_set*, fd_set*, fd_set*, timeval
> > const*) (qcore_unix.cpp:83) =3D=3D33074=3D=3D    by 0x2803B1:
> > select_msecs(int, fd_set*, fd_set*, int) (qprocess_unix.cpp:998)=20
> > =3D=3D33074=3D=3D    by 0x28021D: QProcessPrivate::waitForStarted(int)=
=20
> > (qprocess_unix.cpp:1031) =3D=3D33074=3D=3D    by 0x1FFA02:
> > QProcess::waitForStarted(int) (qprocess.cpp:1687) =3D=3D33074=3D=3D    =
by
> > 0x1FEAEA: QProcess::waitForFinished(int) (qprocess.cpp:1752)=20
> > =3D=3D33074=3D=3D    by 0x805487A: AutoMoc::echoColor(QString const&)=
=20
> > (kde4automoc.cpp:74) =3D=3D33074=3D=3D    by 0x805264F:
> > AutoMoc::generateMoc(QString const&, QString const&)
> > (kde4automoc.cpp:569) =3D=3D33074=3D=3D    by 0x804F13A: AutoMoc::run()
> > (kde4automoc.cpp:470) =3D=3D33074=3D=3D    by 0x804AAEE: main
> > (kde4automoc.cpp:114)
> >=20
> > Full valgrind output is at http://pastebin.com/KQTKYGX5
> >=20
> >>=20
> >> _______________________________________________=20
> >> freebsd-current@freebsd.org mailing list=20
> >> http://lists.freebsd.org/mailman/listinfo/freebsd-current To
> >> unsubscribe, send any mail to
> >> "freebsd-current-unsubscribe@freebsd.org"
>=20
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.19 (FreeBSD)
> Comment: Using GnuPG with undefined - http://www.enigmail.net/
>=20
> iEYEARECAAYFAlDGRiAACgkQrDN5kXnx8yYJFQCgkMYOxkIfFibTaPNOkikw+0Ki
> t3YAoJTCIYecBmk7LT1ehsdQzwhm1Uif
> =3D4Ars
> -----END PGP SIGNATURE-----
>=20
> _______________________________________________
> freebsd-current@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"

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

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

iQIcBAEBAgAGBQJQxkcaAAoJEJDCuSvBvK1BBIEQAKJ7/AcTVwKvufr3co5PTW7y
NvfsTyvJoOLEcHvme2gi4WX+cC/wZPpnRvCZ/of3hZG6VxImi2ABdlzbmcmnhaLA
7ws/mu8onQyXLtZF8r1r2I/SLAWyxtPXjyXZTwDcIyFFCAaKYXRJ4D/N+7lXHwqC
5RfSkTyIeRRqJZ+7L2M2DBqPkk8MXtsXKhkXHj2GzY8aM1KbQSRQ50axLXNIkr/R
DVptmdR0hWiTJRbpyZKosi3ikCMjLjf5aU2s/ry36VEI5fT0so25JV7smE7rKm33
1AJHQSy+uz56zEpzIURGEvEUsYvVkb/TleGV7QXzdrw5pxPnkx3W/IwssErqzWjC
KP4zG/5A7cAaroshX3ICf5Ya3Dad6EQe+jxoHGiGEV2UBzyEwzbnj4E3oL65TfCA
ycXB3WRv7W3D9xfjZrMiIXGXwvTDL6Qbo2Atspjw12ScMCxlRjucbGoYQvjGmiPM
wix5zBbY1NPFvr+BLC2c9dTI0+0Oe/XcDC3QT5lWTD9zsMZ7htloZmJlouwwWgFS
yw7aRVKNyhxGQpiry6MLKnW/DZih9tUD84tBMq3ymEFsE7DIineHVPyQnUS6pf2R
3CxRla+iMOUlauhT4sc3TINTYAJaAVlYsJzX7UE1a+5aKTqZQx0EEiHLfWnYcdJU
LzWCwMMhE5ZciQRbVQ49
=ZNYA
-----END PGP SIGNATURE-----

--V7svHyRZ5yxp1ETC--



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