AMD64 version of GNAT Ada compiler broken due to libthr

Kostik Belousov kostikbel at gmail.com
Fri Dec 31 13:27:11 UTC 2010


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.

> 
> -- John
> 
> 
> 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 
> 0x00000008006923cc in _umtx_op_err () at 
> /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 
> 0x00000008006923cc in _umtx_op_err () at 
> /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 
> 0x00000008006923cc in _umtx_op_err () at 
> /usr/src/lib/libthr/arch/amd64/amd64/_umtx_op_err.S:37
> 37	RSYSCALL_ERR(_umtx_op)
> Continuing.
> 
> Program exited normally.
> 
> 
> 
> 
> 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 tried 
> >>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. 
> >>  Here's the dissembled _umtx_op_err function, along with the 
> >>backtraces of the other two threads.  They didn't look that interesting 
> >>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 = mmap(stackaddr, stacksize+guardsize,
> >		     PROT_READ | PROT_WRITE, MAP_STACK,
> >		     -1, 0)) != 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.
> >
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-threads/attachments/20101231/8198c53b/attachment.pgp


More information about the freebsd-threads mailing list