Re: catch SIGSEGV in the demangler

Tom Tromey
2013-01-18T16:09:15Z

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

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

Pedro> Did you mean to catch the SIGSEGV caused by the raise?
Pedro> That seems like what you'd get if !in_demangler (you got to
Pedro> throw_exception)? You got SIGSEGV set to nopass by mistake
Pedro> perhaps, caught the raise(SIGSEGV), and continued, which
Pedro> suppressed the signal, and moved along into the throw?

I started gdb and kill -SEGV'd it from another terminal.
Then I made the stack trace from the core file.

Ah. SEGV is blocked in the handler. So the raise queues it and then it
falls through to throw_exception. Oops. The fix is to just return.

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

Pedro> I think it does, but we can always do a raise where it doesn't work.

Ok. I'm trying it out.

I'm primarily interested in opinions on whether this is even a good
idea. I'm on the fence about it myself.

It's far from clear that it is safe to call throw_exception from a
signal handler.

Tom