[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patch] get 1.8.8 to build on Solaris 10u9 -- Solaris stack layout

From: Andrew Gaylard
Subject: Re: [patch] get 1.8.8 to build on Solaris 10u9 -- Solaris stack layout
Date: Fri, 29 Apr 2011 23:34:57 +0200

Hi, I don't know if this is useful, but here's some more background...

The old code in guile-1.8.8/libguile/gc_os_dep.c used to do this:

#       define STACKBOTTOM ((ptr_t) USRSTACK)

.. which is mentioned in the Solaris-10 headers...

$ find /usr/include/ | xargs grep USERLIMIT
/usr/include/sys/vmparam.h:#define      USRSTACK        USERLIMIT
/usr/include/sys/vmparam.h:#define      USRSTACK32      USERLIMIT32
/usr/include/sys/param.h:#define        USERLIMIT       _userlimit
/usr/include/sys/param.h:#define        USERLIMIT32     _userlimit32

However, I can't find the _userlimit or _userlimit32 symbols on Solaris 9 or 10.
So I guess Sun/Oracle's changed how this works.  Hence my patch to
guile-1.8.8/libguile/gc_os_dep.c .

I've found these two links which make it pretty clear what the Solaris
stack layout is,
at least in 10 and 11:

If I understand them correctly, the ASCII-art diagrams indicate that
the stack grows
downwards from USERLIMIT, which is set to various values depending on x86/SPARC
and 32-/64-bit,  towards ss_sp.  The maximum size that the stack can grow to is
set by ulimit, and is read in the ss_size field of the struct
populated by stack_getbounds().

Using the stack_getbounds() call, we can do some checks.  This is on

$ cat ./stackbounds.c
#include <ucontext.h>
#include <stdio.h>

int main( int argc, char* argv[] )
        stack_t stack;
        stack_getbounds( &stack );
        printf( "ss_sp=%p\nss_size=%dkiB\nuserlimit=%p\n",
                stack.ss_sp + stack.ss_size );
        return 0;

$ gcc -m64 ./stackbounds.c

$ ./a.out

$ gcc -m32 ./stackbounds.c

$ ./a.out

Clearly, the userlimit values detected here match those of the diagrams in
the Solaris source files. (Solaris-9/SPARC gives the identical output as for
the 32-bit case;  I don't have a 64-bit gcc on the sol-9 box, so I
can't test that.)

On Solaris-10/x86, we get this:

$ gcc -m64 ./stackbounds.c

$ ./a.out

$ gcc -m32 ./stackbounds.c

$ ./a.out

Here, the 64-bit value is pretty close (2048kiB) to the diagram's value of
0xFFFFFD80.00000000, and the 32-bit value matches exactly.

So I'm pretty confident that my patch to guile-1.8.8/libguile/threads.c
does the right thing.  The patch to guile-1.8.8/libguile/gc_os_dep.c
is harder to analyse, since it appears that the "HEURISTIC" code
installs a SEGV handler, and probes around to find the end of the
stack.  However, I tried disabling the heuristics, and setting
# define STACKBOTTOM ((ptr_t)(0xff400000))
in line 714 with no change in the result of test-unwind.  So I'm
pretty sure that this test's failing for other reasons.  And TBH, I'm
reluctant to invest a lot of time in getting guile to work on Solaris-9 :)

I hope this helps,
- Andrew

reply via email to

[Prev in Thread] Current Thread [Next in Thread]