From owner-freebsd-threads@FreeBSD.ORG Fri Dec 31 13:27:11 2010 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4A9AF106566C for ; Fri, 31 Dec 2010 13:27:11 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id D0D8F8FC0A for ; Fri, 31 Dec 2010 13:27:10 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id oBVDR6hP016684 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 31 Dec 2010 15:27:06 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id oBVDR603017213; Fri, 31 Dec 2010 15:27:06 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id oBVDR6GF017212; Fri, 31 Dec 2010 15:27:06 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 31 Dec 2010 15:27:06 +0200 From: Kostik Belousov To: John Marino Message-ID: <20101231132706.GN90883@deviant.kiev.zoral.com.ua> References: <4D1DC299.2090808@marino.st> <20101231122225.GK90883@deviant.kiev.zoral.com.ua> <4D1DCE02.3050601@marino.st> <20101231125215.GL90883@deviant.kiev.zoral.com.ua> <4D1DD5CF.5020305@marino.st> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="i+iWqY68NNxfGGlH" Content-Disposition: inline In-Reply-To: <4D1DD5CF.5020305@marino.st> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-threads@freebsd.org Subject: Re: AMD64 version of GNAT Ada compiler broken due to libthr X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Dec 2010 13:27:11 -0000 --i+iWqY68NNxfGGlH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 31, 2010 at 02:08:31PM +0100, John Marino wrote: > Hi Kostik, > The result is the test passes. A small gdb log follows to prove it. > So what does this mean? This means that the Ada complier or tasking library uses on-stack trampolines for something. Since FreeBSD threads on amd64 get non-executable stacks, the tasking fails. The proper solution is to provide a support for conditional non-executable stacks, as described in http://lists.freebsd.org/pipermail/freebsd-arch/2010-November/010826.html The latest WIP patch is http://people.freebsd.org/~kib/misc/nxstacks.3.patch I hope to get something in the tree not too long. >=20 > -- John >=20 >=20 > Starting program: /usr/home/marino/test_gnat/test_c9a009c/c9a009c > [New LWP 100064] > [New Thread 800a041c0 (LWP 100064)] > [New Thread 800a0ae40 (LWP 100051)] > [New Thread 800a64c80 (LWP 100073)] > [New Thread 800aa1ac0 (LWP 100090)] > [Thread 800aa1ac0 (LWP 100090) exited] > Invalid selected thread. > [Switching to thread 2 (Thread 800a041c0 (LWP 100064))]#0=20 > 0x00000008006923cc in _umtx_op_err () at=20 > /usr/src/lib/libthr/arch/amd64/amd64/_umtx_op_err.S:37 > 37 RSYSCALL_ERR(_umtx_op) > Continuing. > [Thread 800a64c80 (LWP 100073) exited] > Invalid selected thread. > [Switching to thread 2 (Thread 800a041c0 (LWP 100064))]#0=20 > 0x00000008006923cc in _umtx_op_err () at=20 > /usr/src/lib/libthr/arch/amd64/amd64/_umtx_op_err.S:37 > 37 RSYSCALL_ERR(_umtx_op) > Continuing. > [Thread 800a0ae40 (LWP 100051) exited] > Invalid selected thread. > [Switching to thread 2 (Thread 800a041c0 (LWP 100064))]#0=20 > 0x00000008006923cc in _umtx_op_err () at=20 > /usr/src/lib/libthr/arch/amd64/amd64/_umtx_op_err.S:37 > 37 RSYSCALL_ERR(_umtx_op) > Continuing. >=20 > Program exited normally. >=20 >=20 >=20 >=20 > Kostik Belousov wrote: > >On Fri, Dec 31, 2010 at 01:35:14PM +0100, John Marino wrote: > >>Hi Kostik, > >>You're right, that was an oversight. I'm using release 8.1, but I trie= d=20 > >>troubleshooting this months ago on 8.0 and the result was identical. > >> > >>I'm well above my head here. I don't know what I should be looking for= .=20 > >> Here's the dissembled _umtx_op_err function, along with the=20 > >>backtraces of the other two threads. They didn't look that interesting= =20 > >>to me the first time. > >The instruction counter is right before syscall, so I do think that the > >thread was executing the syscall. > > > >Backtrace for LWP 100073 indeed looks interesting, because the address > >0x00007fffffbfeb19 belongs to the area used for stack(s), including > >the thread stacks. > > > >FreeBSD amd64 currently provides non-executable stacks for non-main > >threads, but executable stack for main thread. i386 has no support for > >nx bit on non-PAE kernels. > > > >As a useful experiment, go to src/lib/libthr/thread/thr_stack.c, find > >the following fragment > > > > if ((stackaddr =3D mmap(stackaddr, stacksize+guardsize, > > PROT_READ | PROT_WRITE, MAP_STACK, > > -1, 0)) !=3D MAP_FAILED && > > > >and change the flags from PROT_READ | PROT_WRITE to > >PROT_READ | PROT_WRITE | PROT_EXEC. Then recompile and reinstall libthr, > >and report back what happens with your test. > > --i+iWqY68NNxfGGlH Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk0d2ioACgkQC3+MBN1Mb4gIzACdEJPYCtqMvUMqCBbGttvGSncT GaMAoKf08M+KJWuDFlB5waeG2J4CcSZe =Dj0O -----END PGP SIGNATURE----- --i+iWqY68NNxfGGlH--