From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3884 invoked by alias); 18 Jan 2013 11:22:54 -0000 Received: (qmail 3874 invoked by uid 22791); 18 Jan 2013 11:22:53 -0000 X-SWARE-Spam-Status: No, hits=-7.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_EG X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 18 Jan 2013 11:22:47 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0IBMheV021118 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 18 Jan 2013 06:22:43 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0IBMfTY027483; Fri, 18 Jan 2013 06:22:42 -0500 Message-ID: <50F93081.1090905@redhat.com> Date: Fri, 18 Jan 2013 11:22:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Tom Tromey CC: Pierre Muller , gdb-patches@sourceware.org Subject: Re: catch SIGSEGV in the demangler References: <87fw23o70u.fsf@fleche.redhat.com> <19236.9665638127$1358374641@news.gmane.org> <87622vd2vd.fsf@fleche.redhat.com> In-Reply-To: <87622vd2vd.fsf@fleche.redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-01/txt/msg00411.txt.bz2 On 01/17/2013 07:29 PM, Tom Tromey wrote: > > Then, have a special throw_segv that first looks to see if anything > expects to catch it, and if not, reset the handler and re-raise the > signal. +static void +handle_segv (int sig) +{ + struct gdb_exception except; + + if (!in_demangler) + { + signal (sig, SIG_DFL); + raise (sig); + } The original idea was to do return instead of raise: +static void +handle_segv (int sig) +{ + struct gdb_exception except; + + if (!in_demangler) + { + signal (sig, SIG_DFL); + return; + } SIGSEGV being a synchronous signal, this makes it so that the original instruction that triggered the segv is reexecuted, and the SIGSEGV is raised again. The difference is that this way our handler is transparent -- the segv's siginfo will be more rich, including a si_addr that points at the address that caused the fault, (si_code will still show it was a userspace generated signal), and "handle_segv" will not appear in the backtrace. Did you try that and decided against? -- Pedro Alves