Signal trampoline frame changed location on FreeBSD 9 AMD64?

Konstantin Belousov kostikbel at gmail.com
Wed Jul 25 18:10:48 UTC 2012


On Wed, Jul 25, 2012 at 08:04:41PM +0200, John Marino wrote:
> Hi guys,
> I know this isn't a thread issue, but I'm hoping one of you either knows 
> the answer or can point me to someone that does.
> 
> After I patched lib/libthr/thread/thr_setschedparam.c, all the threading 
> issues with the GNAT testsuite running on FreeBSD 9.0 disappeared.  On 
> i386-FreeBSD, GNAT passes all tests perfectly.
> 
> This is not the case for x86_64-FreeBSD.  GNAT fails all the stack-check 
> / dereference tests.  It can no longer detect when it's at the end of 
> the stack during the unwind process, because it can't find the signal 
> trampoline.
> 
> For FreeBSD, it was easy.  Use the kern.ps_strings sysctl and subtract X 
> from it's address (where X is 128 on i386 and 32 on AMD64).  If the 
> stack pointer is between the addr kern.ps_strings and addr 
> kern.ps_strings - X then it's at the end of the stack.
> 
> For AMD64, according to GDB, it seems the signal trampoline frame is now 
> ahead of the ps_strings address rather than behind it.
> 
> Who can confirm this or conversely tell me how wrong I am?
> By the way, if I'm right, it also breaks the base system's GDB 
> end-of-stack detection as well.  It uses the same algorithm.
> 
> I haven't tested this on FreeBSD 9.1 beta - just 9.0 release.

From quite some time, the signal trampoline was moved into the separate
'shared' page. This was done to allow to remove the executable permissions
from the stack mapping.

BTW, I do see that at least gdb 7.4.1 stock can detect our trampoline.
In-tree gdb indeed have issue understanding signal stack frame.

The way forward is to implement vdso and add dwarf annotation to the
trampoline code.
-------------- 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/20120725/ac0c15ff/attachment.pgp


More information about the freebsd-threads mailing list