Article View: fa.netbsd.ports.alpha
Article #53Re: static link csh/tcsh dumps core
From: Martin Husemann
Date: Sun, 10 Feb 2013 19:05
Date: Sun, 10 Feb 2013 19:05
45 lines
3545 bytes
3545 bytes
Disclaimer: I know ~nothing about alpha asm nor the ABI.
It looks like a bug in setjmp/longjmp to me, but it is subtle as it clobbers
the "gp" register, which seems to fall neither in the caller-saved nor the
callee-saved group, but required to be stable for local function calls.
Gcc source says:
/* Define this macro if the register defined by `PIC_OFFSET_TABLE_REGNUM'
is clobbered by calls. */
/* ??? It is and it isn't. It's required to be valid for a given
function when the function returns. It isn't clobbered by
current_file functions. Moreover, we do not expose the ldgp
until after reload, so we're probably safe. */
/* #define PIC_OFFSET_TABLE_REG_CALL_CLOBBERED */
Now in our __setjmp14 implementation we do not store gp in the jump buffer.
Worse, in __longjmp14 we create a sigcontext from the jump buffer and
use partially unintialized stack memory for this, including the storage
area for uc.uc_mcontext.__gregs[_REG_GP].
Then we do a setcontext() and *BOOM* end up back here with an unaligned
(and probably completely bogus) gp:
Program received signal SIGSEGV, Segmentation fault.
process (catch=<optimized out>) at csh.c:1004
1004 justpr = enterhist; /* execute if not entering history */
(gdb) bt
#0 process (catch=<optimized out>) at csh.c:1004
#1 0x0000000120001f78 in srcunit (unit=<optimized out>,
onlyown=<optimized out>, hflg=<optimized out>) at csh.c:749
#2 0x0000000120002090 in srcfile (f=<optimized out>, onlyown=<optimized out>,
flag=<optimized out>) at csh.c:658
#3 0x0000000120003658 in main (argc=<optimized out>, argv=<optimized out>)
at csh.c:525
Sounds like gcc will reload the gp register after non-local function calls
(whatever that exactly is) and so probably hide the effect in the shared
version.
Does this make sense? If yes, it is easy to fix (but I won't mind someone
with alpha knowledge to beat me to it).
Martin
Technical Details
Message-ID:
<fa.dtkzEUaTbqmaQXQ8Z6eSDU/EUr8@ifi.uio.no>Path:
arc1-ca.pugleaf.net!g1ni3231wig.0!nntp.google.com!goblin3!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mailReferences:
<fa.rKhEP7VkJ+2QlFJGwObTYJ3tqWk@ifi.uio.no> <fa.wb971qeIW2HuFOiNsAMBI3tvty8@ifi.uio.no>Show Full Headers
Complete Article Headers
X-Google-Thread: 10fc82,64bb8d86abe4018c
X-Google-NewGroupId: yes
X-Google-Attributes: gid188a2276fd,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
X-Received: by 10.180.106.73 with SMTP id gs9mr2197578wib.2.1360523118945;
Sun, 10 Feb 2013 11:05:18 -0800 (PST)
Path: arc1-ca.pugleaf.net!g1ni3231wig.0!nntp.google.com!goblin3!goblin1!goblin.stu.neva.ru!uio.no!nntp.uio.no!.POSTED!not-for-mail
From: Martin Husemann <martin@duskware.de>
Newsgroups: fa.netbsd.ports.alpha
Subject: Re: static link csh/tcsh dumps core
Date: Sun, 10 Feb 2013 19:05:18 UTC
Organization: Internet mailing list
Lines: 45
Sender: port-alpha-owner@NetBSD.org
Message-ID: <fa.dtkzEUaTbqmaQXQ8Z6eSDU/EUr8@ifi.uio.no>
References: <fa.rKhEP7VkJ+2QlFJGwObTYJ3tqWk@ifi.uio.no> <fa.wb971qeIW2HuFOiNsAMBI3tvty8@ifi.uio.no>
NNTP-Posting-Host: mail-jess.uio.no
Mime-Version: 1.0
X-Trace: readme.uio.no 1360523118 26218 129.240.7.9 (10 Feb 2013 19:05:18 GMT)
X-Complaints-To: abuse@uio.no
NNTP-Posting-Date: Sun, 10 Feb 2013 19:05:18 +0000 (UTC)
User-Agent: Mutt/1.4.2.3i
Cc: port-alpha@netbsd.org
To: Chuck Cranor <chuck@ece.cmu.edu>
Delivered-To: port-alpha@netbsd.org
X-Virus-Scanned: amavisd-new at NetBSD.org
In-Reply-To: <20130210080731.GA339@mail.duskware.de>
List-Id: port-alpha.NetBSD.org
Original-Date: Sun, 10 Feb 2013 20:05:07 +0100
Original-Message-Id: <20130210190507.GB16496@mail.duskware.de>
Original-References: <20130209021846.GB14983@ece.cmu.edu> <20130210080731.GA339@mail.duskware.de>
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline