Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>,
	       gdb-patches@sourceware.org
Subject: Re: catch SIGSEGV in the demangler
Date: Fri, 18 Jan 2013 16:59:00 -0000	[thread overview]
Message-ID: <50F97F65.1050701@redhat.com> (raw)
In-Reply-To: <87obgm8nbj.fsf@fleche.redhat.com>

On 01/18/2013 04:31 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Pedro> The original idea was to do return instead of raise:
> Pedro> +static void
> Pedro> +handle_segv (int sig)
> Pedro> +{
> Pedro> +  struct gdb_exception except;
> Pedro> +
> Pedro> +  if (!in_demangler)
> Pedro> +    {
> Pedro> +      signal (sig, SIG_DFL);
> Pedro> +      return;
> Pedro> +    }
> 
> This works fine, but has the effect of causing gdb to ignore an explicit
> 'kill -SEGV'.  I had to hack "maint dump-me" to really see it work.

Yeah, you're not supposed to send synchronous signals
asynchronously. :-)

We can detect that using sigaction/SA_SIGINFO, and
then look at si_code, e.g.:

void
handler (int signo, siginfo_t *info)
{
  if (expecting_segv)
    {
      signal (SIGSEGV, SIG_DFL);

      if (info->si_code == SI_USER)
	raise (signo);
      else
	return;
    }
}

Doesn't cover all si_codes, but should work
fine in practice.

-- 
Pedro Alves


  reply	other threads:[~2013-01-18 16:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-14 20:15 RFC: " Tom Tromey
2013-01-16 22:16 ` Pierre Muller
     [not found] ` <19236.9665638127$1358374641@news.gmane.org>
2013-01-17 19:56   ` Tom Tromey
2013-01-18 11:22     ` Pedro Alves
2013-01-18 15:01       ` Tom Tromey
2013-01-18 15:41         ` Pedro Alves
2013-01-18 16:09           ` Tom Tromey
2013-01-18 17:56             ` Pedro Alves
2013-01-18 18:09               ` Tom Tromey
2013-01-18 16:31       ` Tom Tromey
2013-01-18 16:59         ` Pedro Alves [this message]
2013-01-18 17:34     ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50F97F65.1050701@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pierre.muller@ics-cnrs.unistra.fr \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox