Re: trouble trapping SEGV on 2.6.11.2 & 2.6.12-rc4

From: Chris Wright
Date: Tue May 24 2005 - 15:47:57 EST


* Clifford T. Matthews (ctm@xxxxxxxx) wrote:
> The included program dies with a SEGV under 2.6.11.2 and 2.6.12-rc4.
> It doesn't die under 2.4.25. I compiled the kernels myself. The
> distribution is Fedora Core release 3, with glibc 2.3.5.

2.6 has been fixed... So your program (which happens to be slightly
buggy) no longer works as you expected. See below.

> #include <stdio.h>
> #include <unistd.h>
> #include <sys/mman.h>
> #include <stdbool.h>
> #include <assert.h>
> #include <setjmp.h>
> #include <signal.h>
>
> static jmp_buf segv_return;
>
> static void
> segv_handler (int signum_ignored __attribute__((unused)))
> {
> longjmp (segv_return, 1);

siglongjmp

> }
>
> int
> main (void)
> {
> volatile char *volatile addr;
> volatile int n_failures;
>
> addr = (void *) 0x10000L;
> n_failures = 0;
>
> signal (SIGSEGV, segv_handler);
> if (setjmp (segv_return) != 0)

sigsetjmp

> ++n_failures;
> else
> *addr;
>
> printf ("n_failures = %d\n", n_failures);
>
> if (setjmp (segv_return) != 0)

sigsetjmp

> ++n_failures;
> else
> *addr;
>
> printf ("n_failures = %d\n", n_failures);
>
> return 0;
> }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/