Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Aug 2007 20:40:07 GMT
From:      Tijl Coosemans <tijl@ulyssis.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/115469: [kernel] [patch] ptrace(2) signal delivery broken
Message-ID:  <200708242040.l7OKe7FY005137@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/115469; it has been noted by GNATS.

From: Tijl Coosemans <tijl@ulyssis.org>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: kern/115469: [kernel] [patch] ptrace(2) signal delivery broken
Date: Fri, 24 Aug 2007 22:38:10 +0200

 The following session shows the problem. The sample code is
 FreeBSD/i386 specific, but it can be easily adopted to other platforms.
 
 tijl@kalimero gdbsignal% cat segv.c
 #include <sys/ucontext.h>
 #include <signal.h>
 #include <stdio.h>
 
 int sayhi = 0;
 
 void sig_handler( int sig, siginfo_t *si, void *context ) {
         ucontext_t *uctx = context;
         /* skip faulting instruction (assumed to be mov (%eax),%al) */
         uctx->uc_mcontext.mc_eip += 2;
         sayhi = 1;
 }
 
 int main( int argc, char **argv ) {
         char c;
         struct sigaction sa;
         sa.sa_sigaction = &sig_handler;
         sa.sa_flags = SA_SIGINFO;
         sigfillset( &sa.sa_mask );
         sigaction( SIGSEGV, &sa, NULL );
         c = *(( char * ) NULL );
         if( sayhi ) {
                 printf( "hello world!\n" );
         }
         return 0;
 }
 tijl@kalimero gdbsignal% cc -Wall -ggdb -O0 -march=i486 -o segv segv.c
 tijl@kalimero gdbsignal% ./segv
 hello world!
 tijl@kalimero gdbsignal% gdb segv
 GNU gdb 6.1.1 [FreeBSD]
 Copyright 2004 Free Software Foundation, Inc.
 GDB is free software, covered by the GNU General Public License, and you are
 welcome to change it and/or distribute copies of it under certain conditions.
 Type "show copying" to see the conditions.
 There is absolutely no warranty for GDB.  Type "show warranty" for details.
 This GDB was configured as "i386-marcel-freebsd"...
 (gdb) r
 Starting program: /home/tijl/tests/gdbsignal/segv
 
 Program received signal SIGSEGV, Segmentation fault.
 0x080484a9 in main () at segv.c:21
 21              c = *(( char * ) NULL );
 (gdb) c
 Continuing.
 
 Program received signal SIGSEGV, Segmentation fault.
 0x080484ab in main () at segv.c:21
 21              c = *(( char * ) NULL );
 (gdb) c
 Continuing.
 
 Program received signal SIGSEGV, Segmentation fault.
 0x080484ad in main () at segv.c:21
 21              c = *(( char * ) NULL );
 (gdb) c
 Continuing.
 
 Program received signal SIGSEGV, Segmentation fault.
 0x080484af in main () at segv.c:22
 22              if( sayhi ) {
 (gdb) c
 Continuing.
 
 Program received signal SIGSEGV, Segmentation fault.
 0x080484b1 in main () at segv.c:22
 22              if( sayhi ) {
 (gdb) and so on...
 
 
 
 With the patch the gdb session becomes:
 
 tijl@kalimero gdbsignal% gdb segv
 GNU gdb 6.1.1 [FreeBSD]
 Copyright 2004 Free Software Foundation, Inc.
 GDB is free software, covered by the GNU General Public License, and you are
 welcome to change it and/or distribute copies of it under certain conditions.
 Type "show copying" to see the conditions.
 There is absolutely no warranty for GDB.  Type "show warranty" for details.
 This GDB was configured as "i386-marcel-freebsd"...
 (gdb) r
 Starting program: /home/tijl/tests/gdbsignal/segv
 
 Program received signal SIGSEGV, Segmentation fault.
 0x080484a9 in main () at segv.c:21
 21              c = *(( char * ) NULL );
 (gdb) c
 Continuing.
 hello world!
 
 Program exited normally.
 (gdb)
 
 
 
 Since this affects debugging/devlopment in general, maybe this PR
 should get a higher priority than low.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200708242040.l7OKe7FY005137>