All of lore.kernel.org
 help / color / mirror / Atom feed
* x86: SIGTRAP handling differences from 2.4 to 2.6
@ 2003-11-22 18:29 Daniel Barlow
  2003-11-22 19:02 ` Linus Torvalds
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Barlow @ 2003-11-22 18:29 UTC (permalink / raw)
  To: linux-kernel

[-- 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 --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-11-24 23:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-22 18:29 x86: SIGTRAP handling differences from 2.4 to 2.6 Daniel Barlow
2003-11-22 19:02 ` 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

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.