From: Daniel Barlow <dan@telent.net>
To: linux-kernel@vger.kernel.org
Subject: x86: SIGTRAP handling differences from 2.4 to 2.6
Date: Sat, 22 Nov 2003 18:29:00 +0000 [thread overview]
Message-ID: <87k75ss1eb.fsf@noetbook.telent.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 1866 bytes --]
There is a difference between 2.4 (tested in 2.4.23-rc2) and 2.6
(tested in 2.6.0-pre9) in the handling of "int 3" inside a SIGTRAP
handler.
In 2.4, the handler appears to be recursively re-entered. In 2.6 the
task is killed, along with any other tasks that share the same VM (I'm
not talking about thread groups; I have CLONE_PARENT and CLONE_VM set
but not CLONE_THREAD).
I'm not sure what the correct answer is, if indeed it's specified.
For contrast, in FreeBSD 5.1 I'm told that the signal handler runs to
completion and only on exit is it called again. I would suggest that
this behaviour is probably more in keeping with the principle of least
astonishment, but maybe I astonish in atypical ways.
Nasty short brutish test program appended. Change the #if 0 s to #if 1
if you want to see it lay waste to the other threads as well.
I'm reading linux-kernel through the archives, so a CC would be
appreciated if you want me to see answers fast.
---cut here---
#include <signal.h>
#if 0
#include <sched.h>
#include <linux/unistd.h>
#endif
void sigtrap_handler(int sig, struct siginfo *si, void * sc)
{
printf("entered sigtrap handler, %d %x %x\n", sig,si,sc);
sleep(2);
asm("int3" : :);
printf("leaving sigtrap handler, %d %x %x\n", sig,si,sc);
}
void do_stuff()
{
pause();
}
main()
{
struct sigaction sa;
int i,j;
#if 0
i=clone(do_stuff,malloc(1024*1024)+1024*1024,
CLONE_VM|SIGCHLD|CLONE_PARENT,0);
j=clone(do_stuff,malloc(1024*1024)+1024*1024,
CLONE_VM|SIGCHLD|CLONE_PARENT,0);
#endif
sigemptyset(&sa.sa_mask);
sa.sa_sigaction=sigtrap_handler;
sa.sa_flags=SA_SIGINFO|SA_RESTART;
sigaction(SIGTRAP,&sa,0);
printf("go\n");
sleep(2);
asm("int3" : :);
sleep(3600);
}
---cut here---
-dan
--
http://web.metacircles.com/cirCLe_CD - Free Software Lisp/Linux distro
[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]
next reply other threads:[~2003-11-22 18:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-22 18:29 Daniel Barlow [this message]
2003-11-22 19:02 ` x86: SIGTRAP handling differences from 2.4 to 2.6 Linus Torvalds
2003-11-22 22:19 ` Paul Mackerras
2003-11-22 22:40 ` Linus Torvalds
2003-11-23 6:21 ` H. Peter Anvin
2003-11-23 17:59 ` Linus Torvalds
2003-11-24 23:57 ` jw schultz
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=87k75ss1eb.fsf@noetbook.telent.net \
--to=dan@telent.net \
--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.