Re: catch SIGSEGV in the demangler

Pedro Alves
2013-01-18T11:22:54Z

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