From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 594 invoked by alias); 29 Aug 2011 17:14:12 -0000 Received: (qmail 585 invoked by uid 22791); 29 Aug 2011 17:14:10 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-ey0-f169.google.com (HELO mail-ey0-f169.google.com) (209.85.215.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 29 Aug 2011 17:13:53 +0000 Received: by eye22 with SMTP id 22so4085314eye.14 for ; Mon, 29 Aug 2011 10:13:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.14.12.129 with SMTP id 1mr1684337eez.138.1314638031257; Mon, 29 Aug 2011 10:13:51 -0700 (PDT) Received: by 10.14.45.70 with HTTP; Mon, 29 Aug 2011 10:13:50 -0700 (PDT) In-Reply-To: <4E5BADCC.4060809@linaro.org> References: <4E563F58.2060006@redhat.com> <4E5BADCC.4060809@linaro.org> Date: Mon, 29 Aug 2011 17:14:00 -0000 Message-ID: Subject: Re: ARM Linux EABI: unwinding through a segfault handler From: Daniel Jacobowitz To: Ken Werner Cc: Andrew Haley , "gcc@gcc.gnu.org" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg00443.txt.bz2 On Mon, Aug 29, 2011 at 11:18 AM, Ken Werner wrote: > On 08/25/2011 02:26 PM, Andrew Haley wrote: >> >> Throwing an exception through a segfault handler doesn't always work >> on ARM: the attached example fails on current gcc trunk. >> >> panda-9:~ $ g++ segv.cc -fnon-call-exceptions -g >> panda-9:~ $ ./a.out >> terminate called after throwing an instance of 'FoobarException*' >> Aborted >> >> The bug is that _Unwind_GetIPInfo doesn't correctly set ip_before_insn. >> Instead, it always sets it to zero; it should be set to 1 if this >> is a frame created by a signal handler: >> >> >> #define _Unwind_GetIPInfo(context, ip_before_insn) \ >> =A0 (*ip_before_insn =3D 0, _Unwind_GetGR (context, 15)& =A0~(_Unwind_Wo= rd)1) >> >> >> Fixing this on ARM is hard because signal frames aren't specially >> marked as they are on systems that use DWARF unwinder data. =A0I have >> a patch that works on systems where the signal restorer is exactly >> >> =A0 =A0 =A0 =A0 mov =A0 =A0 r7, $SYS_rt_sigreturn >> =A0 =A0 =A0 =A0 swi =A0 =A0 0x0 >> >> It works as a proof of concept, but it's fugly. >> >> So, suggestions welcome. =A0Is there a nice way to detect a signal frame? > > Libunwind also reads the IP to detect signal frames on ARM Linux: > http://git.savannah.gnu.org/gitweb/?p=3Dlibunwind.git;a=3Dblob;f=3Dsrc/ar= m/Gis_signal_frame.c;hb=3DHEAD > > I'd also be interested if there are better approaches to detect them. :) There aren't better ways - this is pretty much the standard for on-stack signal frames :-) I thought we used a handler in GLIBC that was properly annotated, nowadays, but I might be mistaken. --=20 Thanks, Daniel