From: Pedro Alves <palves@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Pedro Alves <palves@redhat.com>,
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:41:00 -0000 [thread overview]
Message-ID: <50F96D16.3030502@redhat.com> (raw)
In-Reply-To: <87pq12a62h.fsf@fleche.redhat.com>
On 01/18/2013 03:01 PM, Tom Tromey wrote:
>>>>>> "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.
Interesting, I'd expect that to be implementation defined.
Catching SIGILL, emulating an unsupported instruction, advancing
the program counter in the passed in context (3rd arg), and returning,
is a not unheard of technique (it's better when the kernel does it,
but still).
>
> It seems to me that the failing spot will still be in the backtrace.
> So, the damage isn't so severe:
You have the failing spot, but lose si_addr, which you can use
to know which address wasn't accessed. True, you can infer that
from the instruction that faulted, but it's not as nice.
>
> (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.
Did you mean to catch the SIGSEGV caused by the raise?
That seems like what you'd get if !in_demangler (you got to
throw_exception)? You got SIGSEGV set to nopass by mistake
perhaps, caught the raise(SIGSEGV), and continued, which
suppressed the signal, and moved along into the throw?
>
> If returning actually works everywhere, I am fine with doing that.
I think it does, but we can always do a raise where it doesn't work.
--
Pedro Alves
next prev parent reply other threads:[~2013-01-18 15:41 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 [this message]
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=50F96D16.3030502@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