need help with ruby-1.8.4

Marius Strobl marius at
Mon Jan 16 15:54:31 PST 2006

On Mon, Jan 16, 2006 at 03:07:14AM +0100, Pav Lucistnik wrote:
> Hi,
> Kris Kennaway hurled this error log on me:
> And I honestly have no clue how to fix it. Any ideas?
> Also, is there a working scratchbox for the committers running sparc64?

If I fix that compile problem miniruby still segfaults while
ruby 1.8.4 is built because of exactly the getcontext(3) related
GCC bug that is described in eval.c (the generated code assumes
that %l2 didn't change after calling getcontext(3) in rb_call0()
here). I'd say it's obvious that the workaround implemented in
ruby can't work; we don't want to tell GCC to not make assumptions
regarding input, output and local registers before calling
getcontext(3) but afterwards. In fact when I additionally move
FUNCTION_CALL_MAY_RETURN_TWICE after calling getcontext(3) in
ruby_setjmp() miniruby no longer segfaults. But then it turned out
that the setjmp(3) approach ruby uses on ia64 apparently is also
sufficient to keep GCC from making assumptions regarding the
registers in question on sparc64. Therefore I'd suggest to remove
the inline asm altogether and move FUNCTION_CALL_MAY_RETURN_TWICE
after getcontext(3) (see attached patch). I verified that this
doesn't break building ruby 1.8.4 on ia64 and that `make test` still
succeeds there (and that miniruby segfaults on both architectures
if just remove FUNCTION_CALL_MAY_RETURN_TWICE altogether).
I'd suggest to check back with the ruby committer "ark" who added
this stuff however.


This mail was scanned by AntiVir Milter.
This product is licensed for non-commercial use.
See for details.
-------------- next part --------------
--- eval.c.orig	Tue Dec 20 14:41:47 2005
+++ eval.c	Mon Jan 16 23:54:25 2006
@@ -129,32 +129,21 @@
  * But it has not the problem because gcc knows setjmp may return twice.
  * gcc detects setjmp and generates setjmp safe code.
- * So setjmp call before getcontext call makes the code somewhat safe.
- * It fix the problem on IA64.
+ * So a setjmp call after the getcontext call makes the code somewhat safe.
+ * It fixes the problem on IA64 and SPARC.
  * It is not required that setjmp is called at run time, since the problem is
  * register usage.
- *
- * Since the magic setjmp is not enough for SPARC,
- * inline asm is used to prohibit registers in register windows.
-#if defined (__GNUC__) && (defined(sparc) || defined(__sparc__))
- ({ __asm__ volatile ("" : : :  \
-    "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%o7", \
-    "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", \
-    "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%i7"); })
 static jmp_buf function_call_may_return_twice_jmp_buf;
 int function_call_may_return_twice_false = 0;
   (function_call_may_return_twice_false ? \
    setjmp(function_call_may_return_twice_jmp_buf) : \
 #define ruby_longjmp(env, val) rb_jump_context(env, val)
 #define ruby_setjmp(j) ((j)->status = 0, \
     getcontext(&(j)->context), \
 typedef jmp_buf rb_jmpbuf_t;

More information about the freebsd-sparc64 mailing list