From owner-freebsd-sparc64@FreeBSD.ORG Mon Jan 16 23:54:31 2006 Return-Path: X-Original-To: freebsd-sparc64@freebsd.org Delivered-To: freebsd-sparc64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 574C516A41F; Mon, 16 Jan 2006 23:54:31 +0000 (GMT) (envelope-from marius@newtrinity.zeist.de) Received: from newtrinity.zeist.de (newtrinity.zeist.de [217.24.217.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id C75E543D45; Mon, 16 Jan 2006 23:54:30 +0000 (GMT) (envelope-from marius@newtrinity.zeist.de) Received: from newtrinity.zeist.de (localhost [127.0.0.1]) by newtrinity.zeist.de (8.12.11/8.12.11/ZEIST.DE) with ESMTP id k0GNsSXa018721; Tue, 17 Jan 2006 00:54:29 +0100 (CET) (envelope-from marius@newtrinity.zeist.de) Received: (from marius@localhost) by newtrinity.zeist.de (8.12.11/8.12.10/Submit) id k0GNsN2b018720; Tue, 17 Jan 2006 00:54:23 +0100 (CET) (envelope-from marius) Date: Tue, 17 Jan 2006 00:54:23 +0100 From: Marius Strobl To: Pav Lucistnik Message-ID: <20060117005423.A17774@newtrinity.zeist.de> References: <1137377234.19156.58.camel@localhost> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="u3/rZRmxL6MmkK24" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <1137377234.19156.58.camel@localhost>; from pav@freebsd.org on Mon, Jan 16, 2006 at 03:07:14AM +0100 X-AntiVirus-modified: yes X-AntiVirus: checked by AntiVir Milter (version: 1.1.2-1; AVE: 6.33.0.27; VDF: 6.33.0.127; host: newtrinity.zeist.de) Cc: freebsd-sparc64@freebsd.org Subject: Re: need help with ruby-1.8.4 X-BeenThere: freebsd-sparc64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the Sparc List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jan 2006 23:54:31 -0000 --u3/rZRmxL6MmkK24 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jan 16, 2006 at 03:07:14AM +0100, Pav Lucistnik wrote: > Hi, > > Kris Kennaway hurled this error log on me: > > http://pointyhat.freebsd.org/errorlogs/sparc64-errorlogs/e.5.2005042909/ruby-1.8.4_1,1.log > > 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. Marius -- This mail was scanned by AntiVir Milter. This product is licensed for non-commercial use. See www.antivir.de for details. --u3/rZRmxL6MmkK24 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch-eval.c" --- 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__)) -#define FUNCTION_CALL_MAY_RETURN_TWICE \ - ({ __asm__ volatile ("" : : : \ - "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%o7", \ - "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", \ - "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%i7"); }) -#else static jmp_buf function_call_may_return_twice_jmp_buf; int function_call_may_return_twice_false = 0; #define FUNCTION_CALL_MAY_RETURN_TWICE \ (function_call_may_return_twice_false ? \ setjmp(function_call_may_return_twice_jmp_buf) : \ 0) -#endif #define ruby_longjmp(env, val) rb_jump_context(env, val) #define ruby_setjmp(j) ((j)->status = 0, \ - FUNCTION_CALL_MAY_RETURN_TWICE, \ getcontext(&(j)->context), \ + FUNCTION_CALL_MAY_RETURN_TWICE, \ (j)->status) #else typedef jmp_buf rb_jmpbuf_t; --u3/rZRmxL6MmkK24--