From owner-freebsd-bugs@FreeBSD.ORG Fri Aug 24 20:40:08 2007 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E6A216A419 for ; Fri, 24 Aug 2007 20:40:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 5AF1913C478 for ; Fri, 24 Aug 2007 20:40:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l7OKe7YB005138 for ; Fri, 24 Aug 2007 20:40:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l7OKe7FY005137; Fri, 24 Aug 2007 20:40:07 GMT (envelope-from gnats) Date: Fri, 24 Aug 2007 20:40:07 GMT Message-Id: <200708242040.l7OKe7FY005137@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Tijl Coosemans Cc: Subject: Re: kern/115469: [kernel] [patch] ptrace(2) signal delivery broken X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Tijl Coosemans List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Aug 2007 20:40:08 -0000 The following reply was made to PR kern/115469; it has been noted by GNATS. From: Tijl Coosemans 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 #include #include 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.