Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Pedro Alves <palves@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 15:01:00 -0000	[thread overview]
Message-ID: <87pq12a62h.fsf@fleche.redhat.com> (raw)
In-Reply-To: <50F93081.1090905@redhat.com> (Pedro Alves's message of "Fri, 18	Jan 2013 11:22:41 +0000")

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> SIGSEGV being a synchronous signal, this makes it so that the
Pedro> original instruction that triggered the segv is reexecuted, and
Pedro> the SIGSEGV is raised again.  The difference is that this way our
Pedro> handler is transparent -- the segv's siginfo will be more rich,
Pedro> including a si_addr that points at the address that caused the
Pedro> fault, (si_code will still show it was a userspace generated
Pedro> signal), and "handle_segv" will not appear in the backtrace.  Did
Pedro> you try that and decided against?

I didn't try, because the C standard says this is undefined behavior:

   If and when the function returns, if the value of sig is SIGFPE,
   SIGILL, SIGSEGV, or any other implementation-defined value
   corresponding to a computational exception, the behavior is
   undefined; otherwise the program will resume execution at the point
   it was interrupted.

I couldn't find anything in POSIX suggesting otherwise.

It seems to me that the failing spot will still be in the backtrace.
So, the damage isn't so severe:

(gdb) bt
#0  0x0000003be3036540 in __sigprocmask (how=2, set=0x2f32850, oset=0x0)
    at ../sysdeps/unix/sysv/linux/ia64/sigprocmask.c:43
#1  0x0000003be303610b in __libc_siglongjmp (env=0x2f32808, val=-1)
    at longjmp.c:36
#2  0x0000003be3c0e179 in longjmp (env=<optimized out>, val=<optimized out>)
    at ../nptl/sysdeps/pthread/pt-longjmp.c:27
#3  0x0000000000722e48 in throw_exception (exception=...)
    at ../../archer/gdb/exceptions.c:234
#4  0x0000000000802a33 in handle_segv (sig=11)
    at ../../archer/gdb/safe-demangle.c:49
#5  <signal handler called>
#6  0x0000003be30e87c8 in __GI___poll (fds=0x2e2cff0, nfds=3, 
    timeout=<optimized out>) at ../sysdeps/unix/sysv/linux/poll.c:83
#7  0x000000000072d1be in gdb_wait_for_event (block=1)
    at ../../archer/gdb/event-loop.c:863


Well, ok, the stack trace is weird, since in this scenario we aren't
actually calling longjmp.  I'm not sure what is going on there.

If returning actually works everywhere, I am fine with doing that.

Tom


  reply	other threads:[~2013-01-18 15:01 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 [this message]
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
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=87pq12a62h.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=pierre.muller@ics-cnrs.unistra.fr \
    /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