From: Ulrich Drepper <drepper@redhat.com>
To: "Kevin B. Hendricks" <kevin.hendricks@sympatico.ca>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Catching SIGSEGV with signal() in 2.6
Date: Mon, 05 Apr 2004 21:08:34 -0700 [thread overview]
Message-ID: <40722D42.90406@redhat.com> (raw)
In-Reply-To: <200404052301.28021.kevin.hendricks@sympatico.ca>
[-- Attachment #1: Type: text/plain, Size: 1300 bytes --]
Kevin B. Hendricks wrote:
> So the code has been wrong since the beginning and we were just "lucky" it
> worked in all pre-2.6 kernels?
The old code depended on undefined behavior.
> 1. before the next use of the handler we use signal again to properly set the
> signal handler (and the set of masked signals).
Where do you set the signal mask? That's the point. You don't. This
means jumping from the signal handler causes the signal to remain
blocked. And then
~~~~
If any of the SIGFPE, SIGILL, SIGSEGV, or SIGBUS signals are generated
while they are blocked, the result is undefined, unless the signal was
generated by the kill() function, the sigqueue() function, or the
raise() function.
~~~~
(see pthread_sigmask in POSIX) comes into play.
The second SIGSEGV signal is created with the signal blocked and since
it's neither of the functions mentioned in the text below which creates
the signal anything can happen. The old kernel queued the signal, the
new kernel terminates the process which is much better IMO. Try the
attached program to see why. Also note, the 2.4 behavior is
inconsistent. If no handler is installed the process is terminated,
regardless of the signal being masked.
--
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
[-- Attachment #2: minsig.c --]
[-- Type: text/x-csrc, Size: 200 bytes --]
#include <signal.h>
int *p;
void
sh (int sig)
{
}
int
main(void)
{
sigset_t s;
sigemptyset (&s);
sigaddset (&s, SIGSEGV);
sigprocmask (SIG_BLOCK, &s, 0);
signal(SIGSEGV, sh);
return *p;
}
next prev parent reply other threads:[~2004-04-06 4:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-06 0:40 Catching SIGSEGV with signal() in 2.6 Kevin B. Hendricks
2004-04-06 2:04 ` Ulrich Drepper
2004-04-06 3:01 ` Kevin B. Hendricks
2004-04-06 4:08 ` Ulrich Drepper [this message]
2004-04-06 12:02 ` Kevin B. Hendricks
2004-04-06 15:53 ` Edgar Toernig
-- strict thread matches above, loose matches on Subject: below --
2004-04-05 15:25 bero
2004-04-05 18:17 ` Jamie Lokier
2004-04-05 19:16 ` Chris Friesen
2004-04-05 20:40 ` Jamie Lokier
2004-04-05 20:59 ` Richard B. Johnson
2004-04-05 21:11 ` Chris Friesen
2004-04-05 21:12 ` Jamie Lokier
2004-04-05 21:23 ` bero
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=40722D42.90406@redhat.com \
--to=drepper@redhat.com \
--cc=kevin.hendricks@sympatico.ca \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.