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

2011-04-29 Thread Andrew Gaylard
[resending -- this time to the list.  Sorry for the noise.]

On Thu, Apr 28, 2011 at 7:55 PM, Andy Wingo wi...@pobox.com wrote:
 Hi Andrew,

 On Thu 28 Apr 2011 17:33, Andrew Gaylard a...@computer.org writes:

 With the attached patch, I can build and run guile-1.8.8 on Solaris.
 It seems that the old logic that used USRSTACK no longer works,
 so I took it out.

 Tested on Solaris 10u9, on both SPARC64 and x86_64.

 Thanks for the patch.  Do you have access to other versions of Solaris?
 We would need to test this patch under them as well.

 Andy

Hi Andy,

I've tested on a Solaris-9 SPARC zone, with these results:

gmake[4]: Entering directory
`/export/home/andrewg/guile/branches/1.8.8/src/guile-1.8.8/test-suite/standalone'
PASS: test-system-cmds
PASS: test-require-extension
PASS: test-bad-identifiers
PASS: test-num2integral
PASS: test-round
PASS: test-gh
PASS: test-asmobs
PASS: test-list
FAIL: test-unwind
PASS: test-conversion
PASS: test-fast-slot-ref
PASS: test-use-srfi
PASS: test-scm-c-read
PASS: test-scm-take-locale-symbol
PASS: test-with-guile-module
PASS: test-scm-with-guile
==
1 of 16 tests failed
Please report to bug-gu...@gnu.org
==

This occurs with and without the patch to guile-1.8.8/libguile/threads.c.
Without the patch to guile-1.8.8/libguile/gc_os_dep.c, the build doesn't
even complete:

gc_os_dep.c: In function `scm_get_stack_base':
gc_os_dep.c:1909: error: `USERLIMIT' undeclared (first use in this function)
gc_os_dep.c:1909: error: (Each undeclared identifier is reported only once
gc_os_dep.c:1909: error: for each function it appears in.)

So this patch is good to go, I think.

I've tried debugging the core left behind by test-unwind by rebuilding with -g,
but I get this far, after which I'm stuck:

Core was generated by
`/export/home/andrewg/guile/branches/1.8.8/src/guile-1.8.8/test-suite/standalone'.
Program terminated with signal 11, Segmentation fault.
#0  0x7f8bf714 in scm_i_dowinds (to=0xfd740, delta=-1,
turn_func=0x7f8b6764 copy_stack, data=0xffbfec10) at dynwind.c:303
303   if (FRAME_P (wind_elt))
(gdb) bt
#0  0x7f8bf714 in scm_i_dowinds (to=0xfd740, delta=-1,
turn_func=0x7f8b6764 copy_stack, data=0xffbfec10) at dynwind.c:303
#1  0x7f8bf6f0 in scm_i_dowinds (to=0xfd750, delta=-2,
turn_func=0x7f8b6764 copy_stack, data=0xffbfec10) at dynwind.c:300
#2  0x7f8b6854 in copy_stack_and_call (continuation=0x105668, val=0x4,
dst=0xffbfeec4) at continuations.c:222
#3  0x7f8b698c in scm_dynthrow (cont=0xfd758, val=0x4) at continuations.c:275
#4  0x7f8b6758 in grow_stack (cont=0x7f9bb6c4, val=0xffbfefd0) at
continuations.c:187
#5  0x7f8b6974 in scm_dynthrow (cont=0x0, val=0x0) at continuations.c:271
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) list
298   SCM wind_key;
299
300   scm_i_dowinds (SCM_CDR (to), 1 + delta, turn_func, data);
301   wind_elt = SCM_CAR (to);
302
303   if (FRAME_P (wind_elt))
304 {
305   if (!FRAME_REWINDABLE_P (wind_elt))
306 scm_misc_error (dowinds,
307 cannot invoke continuation from
this context,
(gdb) p wind_elt
$1 = (SCM) 0x0
(gdb) p to
$2 = (SCM) 0xfd740

I'm pretty sure this is not due to the patch to guile-1.8.8/libguile/threads.c,
since it happens with and without it.

-- 
Andrew



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

2011-04-29 Thread Andrew Gaylard
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  USRSTACKUSERLIMIT
/usr/include/sys/vmparam.h:#define  USRSTACK32  USERLIMIT32
/usr/include/sys/param.h:#defineUSERLIMIT   _userlimit
/usr/include/sys/param.h:#defineUSERLIMIT32 _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:

http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/sun4/os/startup.c#490
http://cvs.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/uts/i86pc/os/startup.c#347

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
Solaris-10/SPARC:

$ 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/1024,
stack.ss_sp + stack.ss_size );
return 0;
}

$ gcc -m64 ./stackbounds.c

$ ./a.out
ss_sp=7f80
ss_size=8192kiB
userlimit=8000

$ gcc -m32 ./stackbounds.c

$ ./a.out
ss_sp=ff40
ss_size=8192kiB
userlimit=ffc0

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
ss_sp=fd7ffee0
ss_size=16384kiB
userlimit=fd7fffe0

$ gcc -m32 ./stackbounds.c

$ ./a.out
ss_sp=7048000
ss_size=16384kiB
userlimit=8048000

Here, the 64-bit value is pretty close (2048kiB) to the diagram's value of
0xFD80., 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)(0xff40))
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



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

2011-04-28 Thread Andy Wingo
Hi Andrew,

On Thu 28 Apr 2011 17:33, Andrew Gaylard a...@computer.org writes:

 With the attached patch, I can build and run guile-1.8.8 on Solaris.
 It seems that the old logic that used USRSTACK no longer works,
 so I took it out.

 Tested on Solaris 10u9, on both SPARC64 and x86_64.

Thanks for the patch.  Do you have access to other versions of Solaris?
We would need to test this patch under them as well.

Andy
-- 
http://wingolog.org/



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

2011-04-28 Thread Nelson H. F. Beebe
  Tested on Solaris 10u9, on both SPARC64 and x86_64.

I've just successfully applied Andrew Gaylard's patch for
guile-1.8.8 on Solaris SPARC, and got a successful build
and installation. We have this version:

% cat /etc/release 
Solaris 10 5/09 s10s_u7wos_08 SPARC
...

I'd already installed the stock 1.8.8 release on three different
Solaris 10 Intel boxes, and an OpenSolaris 11 Intel box.

---
- Nelson H. F. BeebeTel: +1 801 581 5254  -
- University of UtahFAX: +1 801 581 4148  -
- Department of Mathematics, 110 LCBInternet e-mail: be...@math.utah.edu  -
- 155 S 1400 E RM 233   be...@acm.org  be...@computer.org -
- Salt Lake City, UT 84112-0090, USAURL: http://www.math.utah.edu/~beebe/ -
---