From nobody@FreeBSD.org  Mon Jan 28 19:11:35 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EA41516A418
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 28 Jan 2008 19:11:35 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id DA4F313C442
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 28 Jan 2008 19:11:35 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m0SJ9pH3006154
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 28 Jan 2008 19:09:51 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m0SJ9p8H006153;
	Mon, 28 Jan 2008 19:09:51 GMT
	(envelope-from nobody)
Message-Id: <200801281909.m0SJ9p8H006153@www.freebsd.org>
Date: Mon, 28 Jan 2008 19:09:51 GMT
From: Christoph Mallon <christoph.mallon@gmx.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: gdb fails to catch signals when threading is involved
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         120095
>Category:       bin
>Synopsis:       gdb(1) fails to catch signals when threading is involved
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 28 19:20:02 UTC 2008
>Closed-Date:    
>Last-Modified:  Mon Jan 28 23:15:05 UTC 2008
>Originator:     Christoph Mallon
>Release:        RELENG_6_2 (applies to newer releases, including 8.x, too)
>Organization:
-
>Environment:
FreeBSD tron.homeunix.org 6.2-STABLE FreeBSD 6.2-STABLE #1: Sun Aug 26 08:02:41 CEST 2007     root@tron.homeunix.org:/usr/obj/usr/src/sys/KERNEL  i386
>Description:
GDB is not able to catch signals from threaded processes, even if no
extra threads get created. According to rwatson@ this is probably a kernel-
side signal handling problem and he can reproduce this on 8.x, too (though
instead of -pthread he used -lkse, because the standard threading
implementation was changed).

Building the test program below with the different thread libraries gives
the following results:

[WORKS] no threading: (cc -ggdb test.c)
(gdb) r
Starting program: /usr/home/tron/a.out 

Program received signal SIGABRT, Aborted.
0x2814cc47 in kill () from /lib/libc.so.6
(gdb)


[BROKEN] pthread (KSE on my 6.x box): (cc -ggdb -pthread test.c)
(gdb) r
Starting program: /usr/home/tron/a.out 
warning: Unable to get location for thread creation breakpoint: generic error
[New LWP 100103]

Program exited normally.
(gdb)


[WORKS] libthr: (cc -ggdb -lthr test.c)
(gdb) r
Starting program: /usr/home/tron/a.out 
[New LWP 100118]
[New Thread 0x804b000 (LWP 100118)]

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x804b000 (LWP 100118)]
0x2815fc47 in kill () from /lib/libc.so.6
(gdb)


[BROKEN] libc_r: (cc -ggdb -lc_r test.c)
(gdb) r
Starting program: /usr/home/tron/a.out 
warning: Unable to get location for thread creation breakpoint: generic error
[New LWP 100185]
Cannot find thread, Thread ID=1, generic error
(gdb)
>How-To-Repeat:
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
int main(void) { kill(getpid(), SIGABRT); }
>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:
