x86: SIGTRAP handling differences from 2.4 to 2.6
From: Daniel Barlow
Date: Sat Nov 22 2003 - 13:30:34 EST
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:
pgp00001.pgp
Description: PGP signature