From owner-freebsd-threads@FreeBSD.ORG Sun Jun 4 23:52:28 2006 Return-Path: X-Original-To: freebsd-threads@hub.freebsd.org Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 42CDA16AE6C; Sun, 4 Jun 2006 23:52:28 +0000 (UTC) (envelope-from rodrigc@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 94BF643D5C; Sun, 4 Jun 2006 23:52:27 +0000 (GMT) (envelope-from rodrigc@FreeBSD.org) Received: from freefall.freebsd.org (rodrigc@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k54NqRMJ068736; Sun, 4 Jun 2006 23:52:27 GMT (envelope-from rodrigc@freefall.freebsd.org) Received: (from rodrigc@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k54NqOip068732; Sun, 4 Jun 2006 23:52:24 GMT (envelope-from rodrigc) Date: Sun, 4 Jun 2006 23:52:24 GMT From: Craig Rodrigues Message-Id: <200606042352.k54NqOip068732@freefall.freebsd.org> To: alo@iki.fi, rodrigc@FreeBSD.org, freebsd-threads@FreeBSD.org Cc: Subject: Re: kern/41331: Pthread library open sets O_NONBLOCK flag and causes unnecessary EAGAIN errors especially with /dev/stdout. X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Jun 2006 23:52:29 -0000 Synopsis: Pthread library open sets O_NONBLOCK flag and causes unnecessary EAGAIN errors especially with /dev/stdout. State-Changed-From-To: open->closed State-Changed-By: rodrigc State-Changed-When: Sun Jun 4 23:52:05 UTC 2006 State-Changed-Why: New libpthread in FreeBSD 5.x does not exhibit this problem. http://www.freebsd.org/cgi/query-pr.cgi?pr=41331 From owner-freebsd-threads@FreeBSD.ORG Mon Jun 5 00:30:47 2006 Return-Path: X-Original-To: freebsd-threads@hub.freebsd.org Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 575E416A75F; Mon, 5 Jun 2006 00:30:47 +0000 (UTC) (envelope-from rodrigc@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0C05043D45; Mon, 5 Jun 2006 00:30:47 +0000 (GMT) (envelope-from rodrigc@FreeBSD.org) Received: from freefall.freebsd.org (rodrigc@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k550UkGF072026; Mon, 5 Jun 2006 00:30:46 GMT (envelope-from rodrigc@freefall.freebsd.org) Received: (from rodrigc@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k550UkcC072022; Mon, 5 Jun 2006 00:30:46 GMT (envelope-from rodrigc) Date: Mon, 5 Jun 2006 00:30:46 GMT From: Craig Rodrigues Message-Id: <200606050030.k550UkcC072022@freefall.freebsd.org> To: earl_chew@agilent.com, rodrigc@FreeBSD.org, freebsd-threads@FreeBSD.org Cc: Subject: Re: kern/24641: pthread_rwlock_rdlock can deadlock X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jun 2006 00:30:48 -0000 Synopsis: pthread_rwlock_rdlock can deadlock State-Changed-From-To: open->closed State-Changed-By: rodrigc State-Changed-When: Mon Jun 5 00:28:27 UTC 2006 State-Changed-Why: Problem does not occur in libpthread in FreeBSD 6.x. Your testcase needs to be modified slightly. If you call pthread_join(), then if you call pthread_detach() later on, pthread_detach may return EINVAL, because the thread may already be terminated and detached, so you can't detach it. #include #include #include #include #include static pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; static volatile int wrStarted; void * wrfunc(void *unused) { wrStarted = 1; printf("Attempt to acquire write lock\n"); assert(pthread_rwlock_wrlock(&rwlock1) == 0); printf("Acquired write lock\n"); assert(pthread_rwlock_unlock(&rwlock1) == 0); return 0; } static volatile int rdStarted; void * rdfunc(void *unused) { printf("Attempt to acquire read lock first\n"); assert(pthread_rwlock_rdlock(&rwlock1) == 0); printf("Acquired read lock first\n"); rdStarted = 1; while (wrStarted == 0) sleep(1); printf("Attempt to acquire read lock second\n"); assert(pthread_rwlock_rdlock(&rwlock1) == 0); printf("Acquired read lock second\n"); assert(pthread_rwlock_unlock(&rwlock1) == 0); assert(pthread_rwlock_unlock(&rwlock1) == 0); return 0; } int main(int argc, char **argv) { pthread_t wrt; pthread_t rdt; pthread_attr_t a; int ret; assert(pthread_rwlock_init(&rwlock1, 0) == 0); assert(pthread_attr_init(&a) == 0); assert(pthread_create(&rdt, &a, rdfunc, NULL) == 0); while (rdStarted == 0) sleep(1); assert(pthread_create(&wrt, &a, wrfunc, NULL) == 0); assert(pthread_join(wrt, 0) == 0); assert(pthread_join(rdt, 0) == 0); assert(pthread_rwlock_destroy(&rwlock1) == 0); if ((ret = pthread_detach(wrt)) != 0) { if (ret == EINVAL) { printf("wrt already detached\n"); } } if ((ret = pthread_detach(rdt)) != 0) { if (errno == EINVAL) { printf("rdt already detached\n"); } } return 0; } http://www.freebsd.org/cgi/query-pr.cgi?pr=24641 From owner-freebsd-threads@FreeBSD.ORG Mon Jun 5 11:03:20 2006 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 317DE16A484 for ; Mon, 5 Jun 2006 11:03:20 +0000 (UTC) (envelope-from owner-bugmaster@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E6ABD43D48 for ; Mon, 5 Jun 2006 11:03:19 +0000 (GMT) (envelope-from owner-bugmaster@freebsd.org) Received: from freefall.freebsd.org (peter@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k55B3JV0010442 for ; Mon, 5 Jun 2006 11:03:19 GMT (envelope-from owner-bugmaster@freebsd.org) Received: (from peter@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k55B3I8J010438 for freebsd-threads@freebsd.org; Mon, 5 Jun 2006 11:03:18 GMT (envelope-from owner-bugmaster@freebsd.org) Date: Mon, 5 Jun 2006 11:03:18 GMT Message-Id: <200606051103.k55B3I8J010438@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: peter set sender to owner-bugmaster@freebsd.org using -f From: FreeBSD bugmaster To: freebsd-threads@FreeBSD.org Cc: Subject: Current problem reports assigned to you X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jun 2006 11:03:21 -0000 Current FreeBSD problem reports Critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- s [2005/01/26] threads/76690threads fork hang in child for (-lc_r & -lthr) 1 problem total. Serious problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- o [2000/07/18] kern/20016 threads pthreads: Cannot set scheduling timer/Can s [2001/01/20] threads/24472threads libc_r does not honor SO_SNDTIMEO/SO_RCVT s [2001/01/25] threads/24632threads libc_r delicate deviation from libc in ha s [2001/11/26] bin/32295 threads pthread dont dequeue signals s [2002/02/01] threads/34536threads accept() blocks other threads o [2002/05/25] kern/38549 threads the procces compiled whith pthread stoppe s [2002/06/27] threads/39922threads [threads] [patch] Threaded applications e s [2003/03/02] threads/48856threads Setting SIGCHLD to SIG_IGN still leaves z s [2003/03/10] threads/49087threads Signals lost in programs linked with libc s [2004/03/15] kern/64313 threads FreeBSD (OpenBSD) pthread implicit set/un o [2004/08/26] threads/70975threads unexpected and unreliable behaviour when o [2004/10/05] threads/72353threads Assertion fails in /usr/src/lib/libpthrea o [2004/10/07] threads/72429threads threads blocked in stdio (fgets, etc) are o [2004/10/21] threads/72953threads fork() unblocks blocked signals w/o PTHRE o [2004/12/19] threads/75273threads FBSD 5.3 libpthread (KSE) bug o [2004/12/21] threads/75374threads pthread_kill() ignores SA_SIGINFO flag s [2005/01/26] threads/76694threads fork cause hang in dup()/close() function o [2005/04/08] threads/79683threads svctcp_create() fails if multiple threads o [2005/04/28] threads/80435threads panic on high loads o [2005/05/19] threads/81258threads Thread specific data is sometimes assigne o [2005/07/22] threads/83914threads [libc] popen() doesn't work in static thr s [2005/08/02] threads/84483threads problems with devel/nspr and -lc_r on 4.x o [2005/08/20] threads/85160threads [libthr] [patch] libobjc + libpthread/lib p [2005/11/19] threads/89262threads [kernel] [patch] multi-threaded process h o [2005/12/12] threads/90278threads libthr, ULE and -current produces >100% W o [2006/01/03] kern/91266 threads [threads] Trying sleep, but thread marked s [2006/03/15] threads/94467threads send(), sendto() and sendmsg() are not co o [2006/06/01] threads/98256threads gnome-system-monitor core dumps from pthr 28 problems total. Non-critical problems S Submitted Tracker Resp. Description ------------------------------------------------------------------------------- s [2000/06/13] kern/19247 threads uthread_sigaction.c does not do anything s [2000/10/21] kern/22190 threads A threaded read(2) from a socketpair(2) f s [2001/09/09] threads/30464threads pthread mutex attributes -- pshared s [2002/05/02] threads/37676threads libc_r: msgsnd(), msgrcv(), pread(), pwri s [2002/07/16] threads/40671threads pthread_cancel doesn't remove thread from s [2004/07/13] threads/69020threads pthreads library leaks _gc_mutex o [2004/09/21] threads/71966threads Mlnet Core Dumped : Fatal error '_pq_inse o [2004/11/21] threads/74180threads KSE problem. Applications those riched ma o [2005/04/13] threads/79887threads [patch] freopen() isn't thread-safe o [2005/05/13] threads/80992threads abort() sometimes not caught by gdb depen o [2005/05/26] threads/81534threads [libc_r] [patch] libc_r close() will fail 11 problems total. From owner-freebsd-threads@FreeBSD.ORG Thu Jun 8 01:34:48 2006 Return-Path: X-Original-To: threads@freebsd.org Delivered-To: freebsd-threads@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B58BE16A85B for ; Wed, 7 Jun 2006 23:06:38 +0000 (UTC) (envelope-from mi+mx@aldan.algebra.com) Received: from aldan.algebra.com (aldan.algebra.com [216.254.65.224]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3EB6843D48 for ; Wed, 7 Jun 2006 23:06:38 +0000 (GMT) (envelope-from mi+mx@aldan.algebra.com) Received: from corbulon.video-collage.com (static-151-204-231-237.bos.east.verizon.net [151.204.231.237]) by aldan.algebra.com (8.13.6/8.13.6) with ESMTP id k57N6aZn023618 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 7 Jun 2006 19:06:37 -0400 (EDT) (envelope-from mi+mx@aldan.algebra.com) Received: from [172.21.130.86] (mx-broadway [38.98.68.18]) by corbulon.video-collage.com (8.13.6/8.13.6) with ESMTP id k57N6VXq083822 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 7 Jun 2006 19:06:31 -0400 (EDT) (envelope-from mi+mx@aldan.algebra.com) From: Mikhail Teterin Organization: Virtual Estates, Inc. To: threads@freebsd.org Date: Wed, 7 Jun 2006 19:06:25 -0400 User-Agent: KMail/1.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200606071906.25776.mi+mx@aldan.algebra.com> X-Virus-Scanned: ClamAV 0.88/1519/Wed Jun 7 15:17:46 2006 on corbulon.video-collage.com X-Virus-Status: Clean X-Scanned-By: MIMEDefang 2.43 Cc: Subject: SIGINFO and pthreads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jun 2006 01:34:57 -0000 Hello! I have a program, which updates the user with its status upon receiving a SIGINFO (like dump, cp, dd, and fsck do). The exact same handler is installed for SIGUSR1 (TclX does not know about SIGINFO and I needed to a Tcl script to interact with the program too). When I made the program multi-threaded, it stopped reacting to the SIGINFO. It still reacts to the SIGUSR1, but completele ignores SIGINFO now... If I disable the multi-threading, SIGINFO is processed again... What's special about SIGINFO and pthreads? Thanks! -mi From owner-freebsd-threads@FreeBSD.ORG Thu Jun 8 01:37:19 2006 Return-Path: X-Original-To: threads@freebsd.org Delivered-To: freebsd-threads@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 920F516E2B2 for ; Wed, 7 Jun 2006 23:16:51 +0000 (UTC) (envelope-from mi+mx@aldan.algebra.com) Received: from aldan.algebra.com (aldan.algebra.com [216.254.65.224]) by mx1.FreeBSD.org (Postfix) with ESMTP id 06E7643D48 for ; Wed, 7 Jun 2006 23:16:50 +0000 (GMT) (envelope-from mi+mx@aldan.algebra.com) Received: from corbulon.video-collage.com (static-151-204-231-237.bos.east.verizon.net [151.204.231.237]) by aldan.algebra.com (8.13.6/8.13.6) with ESMTP id k57NGnUx023647 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 7 Jun 2006 19:16:50 -0400 (EDT) (envelope-from mi+mx@aldan.algebra.com) Received: from [172.21.130.86] (mx-broadway [38.98.68.18]) by corbulon.video-collage.com (8.13.6/8.13.6) with ESMTP id k57NGhex083969 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 7 Jun 2006 19:16:44 -0400 (EDT) (envelope-from mi+mx@aldan.algebra.com) From: Mikhail Teterin Organization: Virtual Estates, Inc. To: threads@freebsd.org Date: Wed, 7 Jun 2006 19:16:38 -0400 User-Agent: KMail/1.9.1 References: <200606071906.25776.mi+mx@aldan.algebra.com> In-Reply-To: <200606071906.25776.mi+mx@aldan.algebra.com> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_W51hEkL9F26JpFW" Message-Id: <200606071916.38538.mi+mx@aldan.algebra.com> X-Virus-Scanned: ClamAV 0.88/1519/Wed Jun 7 15:17:46 2006 on corbulon.video-collage.com X-Virus-Status: Clean X-Scanned-By: MIMEDefang 2.43 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: Re: SIGINFO and pthreads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jun 2006 01:37:33 -0000 --Boundary-00=_W51hEkL9F26JpFW Content-Type: text/plain; charset="koi8-u" Content-Transfer-Encoding: 8bit Content-Disposition: inline ÓÅÒÅÄÁ 07 ÞÅÒ×ÅÎØ 2006 19:06, Mikhail Teterin ÎÁÐÉÓÁ×: > If I disable the multi-threading, SIGINFO is processed again... Indeed, depending on whether the attached simple program is linked without or with -pthread, it reacts or does not react to SIGINFO... -mi --Boundary-00=_W51hEkL9F26JpFW-- From owner-freebsd-threads@FreeBSD.ORG Thu Jun 8 06:25:11 2006 Return-Path: X-Original-To: threads@freebsd.org Delivered-To: freebsd-threads@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 640CF16AC0F for ; Thu, 8 Jun 2006 03:40:29 +0000 (UTC) (envelope-from maxim@macomnet.ru) Received: from mp2.macomnet.net (mp2.macomnet.net [195.128.64.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id BBED543D45 for ; Thu, 8 Jun 2006 03:40:28 +0000 (GMT) (envelope-from maxim@macomnet.ru) Received: from localhost (localhost [127.0.0.1]) by mp2.macomnet.net (8.13.4/8.13.3) with ESMTP id k583e9si006404; Thu, 8 Jun 2006 07:40:13 +0400 (MSD) (envelope-from maxim@macomnet.ru) Date: Thu, 8 Jun 2006 07:40:09 +0400 (MSD) From: Maxim Konovalov To: Mikhail Teterin In-Reply-To: <200606071906.25776.mi+mx@aldan.algebra.com> Message-ID: <20060608073336.C6097@mp2.macomnet.net> References: <200606071906.25776.mi+mx@aldan.algebra.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: threads@freebsd.org Subject: Re: SIGINFO and pthreads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jun 2006 06:25:16 -0000 Hi, On Wed, 7 Jun 2006, 19:06-0400, Mikhail Teterin wrote: > Hello! > > I have a program, which updates the user with its status upon > receiving a SIGINFO (like dump, cp, dd, and fsck do). The exact same > handler is installed for SIGUSR1 (TclX does not know about SIGINFO > and I needed to a Tcl script to interact with the program too). > > When I made the program multi-threaded, it stopped reacting to the > SIGINFO. It still reacts to the SIGUSR1, but completele ignores > SIGINFO now... > > If I disable the multi-threading, SIGINFO is processed again... > > What's special about SIGINFO and pthreads? Thanks! libpthread uses SIGINFO for dumping thread information to a file but looking over the code it seems it does allow to use SIGINFO to the app. Are you sure your signal handling is correct? Signal handling in pthreads programs is tricky, e.g. all threads share signal actions but each thread has a separate signal mask. -- Maxim Konovalov From owner-freebsd-threads@FreeBSD.ORG Thu Jun 8 06:27:29 2006 Return-Path: X-Original-To: threads@freebsd.org Delivered-To: freebsd-threads@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0717C16E297 for ; Thu, 8 Jun 2006 04:17:50 +0000 (UTC) (envelope-from maxim@macomnet.ru) Received: from mp2.macomnet.net (mp2.macomnet.net [195.128.64.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2CA6A43D45 for ; Thu, 8 Jun 2006 04:17:48 +0000 (GMT) (envelope-from maxim@macomnet.ru) Received: from localhost (localhost [127.0.0.1]) by mp2.macomnet.net (8.13.4/8.13.3) with ESMTP id k584He3h006824; Thu, 8 Jun 2006 08:17:44 +0400 (MSD) (envelope-from maxim@macomnet.ru) Date: Thu, 8 Jun 2006 08:17:40 +0400 (MSD) From: Maxim Konovalov To: Mikhail Teterin In-Reply-To: <200606071916.38538.mi+mx@aldan.algebra.com> Message-ID: <20060608081626.X6097@mp2.macomnet.net> References: <200606071906.25776.mi+mx@aldan.algebra.com> <200606071916.38538.mi+mx@aldan.algebra.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=KOI8-R Content-Transfer-Encoding: 8BIT Cc: threads@freebsd.org Subject: Re: SIGINFO and pthreads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jun 2006 06:27:35 -0000 On Wed, 7 Jun 2006, 19:16-0400, Mikhail Teterin wrote: > ÓÅÒÅÄÁ 07 ÞÅÒ×ÅÎØ 2006 19:06, Mikhail Teterin ÎÁÐÉÓÁ×: > > If I disable the multi-threading, SIGINFO is processed again... > > Indeed, depending on whether the attached simple program is linked > without or with -pthread, it reacts or does not react to SIGINFO... Inline it if it's small. Mailman strips most attachments. -- Maxim Konovalov From owner-freebsd-threads@FreeBSD.ORG Thu Jun 8 09:57:56 2006 Return-Path: X-Original-To: threads@freebsd.org Delivered-To: freebsd-threads@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A1C2016B3EE for ; Thu, 8 Jun 2006 08:51:03 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from fw.zoral.com.ua (ll-227.216.82.212.sovam.net.ua [212.82.216.227]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3DC8C43D4C for ; Thu, 8 Jun 2006 08:51:01 +0000 (GMT) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by fw.zoral.com.ua (8.13.4/8.13.4) with ESMTP id k588nuGB006630 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 8 Jun 2006 11:49:56 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.13.6/8.13.6) with ESMTP id k588oYZi065205; Thu, 8 Jun 2006 11:50:34 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.13.6/8.13.6/Submit) id k588oWnP065158; Thu, 8 Jun 2006 11:50:32 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 8 Jun 2006 11:50:32 +0300 From: Konstantin Belousov To: Mikhail Teterin Message-ID: <20060608085032.GD54415@deviant.kiev.zoral.com.ua> References: <200606071906.25776.mi+mx@aldan.algebra.com> <200606071916.38538.mi+mx@aldan.algebra.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ieNMXl1Fr3cevapt" Content-Disposition: inline In-Reply-To: <200606071916.38538.mi+mx@aldan.algebra.com> User-Agent: Mutt/1.4.2.1i X-Virus-Scanned: ClamAV version 0.88.2, clamav-milter version 0.88.2 on fw.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED autolearn=failed version=3.1.1 X-Spam-Checker-Version: SpamAssassin 3.1.1 (2006-03-10) on fw.zoral.com.ua Cc: threads@freebsd.org Subject: Re: SIGINFO and pthreads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jun 2006 09:58:00 -0000 --ieNMXl1Fr3cevapt Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 07, 2006 at 07:16:38PM -0400, Mikhail Teterin wrote: > =D3=C5=D2=C5=C4=C1 07 =DE=C5=D2=D7=C5=CE=D8 2006 19:06, Mikhail Teterin = =CE=C1=D0=C9=D3=C1=D7: > > If I disable the multi-threading, SIGINFO is processed again... >=20 > Indeed, depending on whether the attached simple program is linked withou= t or=20 > with -pthread, it reacts or does not react to SIGINFO... >=20 > -mi libpthread usurps SIGINFO for debug purposes. Look at libpthread/thread/thr_sig.c. As far as I remember, this was so even in times of libc_r. --ieNMXl1Fr3cevapt Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (FreeBSD) iD8DBQFEh+TYC3+MBN1Mb4gRAqvTAKCRRpLzwymvo+s9H94pkFj2N073kwCg719F yJOqipJGpGsp0Lq7jxBShWE= =jCEw -----END PGP SIGNATURE----- --ieNMXl1Fr3cevapt-- From owner-freebsd-threads@FreeBSD.ORG Thu Jun 8 14:56:56 2006 Return-Path: X-Original-To: threads@freebsd.org Delivered-To: freebsd-threads@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5141C16ABCF for ; Thu, 8 Jun 2006 12:59:50 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id E813D43D46 for ; Thu, 8 Jun 2006 12:59:49 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.6/8.13.6/NETPLEX) with ESMTP id k58CxYG7012512; Thu, 8 Jun 2006 08:59:34 -0400 (EDT) Date: Thu, 8 Jun 2006 08:59:34 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Mikhail Teterin In-Reply-To: <200606071906.25776.mi+mx@aldan.algebra.com> Message-ID: References: <200606071906.25776.mi+mx@aldan.algebra.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) Cc: threads@freebsd.org Subject: Re: SIGINFO and pthreads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jun 2006 14:56:57 -0000 On Wed, 7 Jun 2006, Mikhail Teterin wrote: > Hello! > > I have a program, which updates the user with its status upon receiving a > SIGINFO (like dump, cp, dd, and fsck do). The exact same handler is installed > for SIGUSR1 (TclX does not know about SIGINFO and I needed to a Tcl script to > interact with the program too). > > When I made the program multi-threaded, it stopped reacting to the SIGINFO. It > still reacts to the SIGUSR1, but completele ignores SIGINFO now... > > If I disable the multi-threading, SIGINFO is processed again... > > What's special about SIGINFO and pthreads? Thanks! Look in /tmp. In -current, dumping of threads is only enabled when LIBPTHREAD_DEBUG is set in the environment. -- DE From owner-freebsd-threads@FreeBSD.ORG Thu Jun 8 18:15:47 2006 Return-Path: X-Original-To: threads@freebsd.org Delivered-To: freebsd-threads@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B475116B20A for ; Thu, 8 Jun 2006 16:18:34 +0000 (UTC) (envelope-from mi+mx@aldan.algebra.com) Received: from aldan.algebra.com (aldan.algebra.com [216.254.65.224]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4467F43D5D for ; Thu, 8 Jun 2006 16:18:32 +0000 (GMT) (envelope-from mi+mx@aldan.algebra.com) Received: from corbulon.video-collage.com (static-151-204-231-237.bos.east.verizon.net [151.204.231.237]) by aldan.algebra.com (8.13.6/8.13.6) with ESMTP id k58GIS8H032244 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 8 Jun 2006 12:18:29 -0400 (EDT) (envelope-from mi+mx@aldan.algebra.com) Received: from [172.21.130.86] (mx-broadway [38.98.68.18]) by corbulon.video-collage.com (8.13.6/8.13.6) with ESMTP id k58GIM1v030550 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 8 Jun 2006 12:18:23 -0400 (EDT) (envelope-from mi+mx@aldan.algebra.com) From: Mikhail Teterin Organization: Virtual Estates, Inc. To: Maxim Konovalov Date: Thu, 8 Jun 2006 12:18:16 -0400 User-Agent: KMail/1.9.1 References: <200606071906.25776.mi+mx@aldan.algebra.com> <200606071916.38538.mi+mx@aldan.algebra.com> <20060608081626.X6097@mp2.macomnet.net> In-Reply-To: <20060608081626.X6097@mp2.macomnet.net> MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200606081218.17131.mi+mx@aldan.algebra.com> X-Virus-Scanned: ClamAV 0.88/1520/Wed Jun 7 17:47:18 2006 on corbulon.video-collage.com X-Virus-Status: Clean X-Scanned-By: MIMEDefang 2.43 Cc: threads@freebsd.org Subject: Re: SIGINFO and pthreads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jun 2006 18:15:48 -0000 ÞÅÔ×ÅÒ 08 ÞÅÒ×ÅÎØ 2006 00:17, Maxim Konovalov ÎÁÐÉÓÁ×: > Inline it if it's small. šMailman strips most attachments. Damn... Yes, it is small -- this is just a demo program. Compile it first as cc -o t t.c Then -- run and try various keyboard signals like Ctrl-C, Ctrl-Z, Ctrl-T (SIGINFO), or Ctrl-\. (It will not quit on its own, you'll have to kill it from another prompt.) They will all work. Then -- recompile as cc -o t -pthread t.c And run... This time around it will ignore the Ctrl-T, while continuing to respond to others. > libpthread uses SIGINFO for dumping thread information to a file but > looking over the code it seems it does allow to use SIGINFO to the > app. I'd like to be able to disable the debugging feature or, at least, force it to call my signal-handler AS EXPECTED AND DOCUMENTED, after it is done with its own dumping. -mi #include #include #include #include static void sigfunc(int signum) { printf("Received signal %d\n", signum); } int main(int argc, char *argv[]) { int i; for (i = 1; i < 32; i++) if (signal(i, sigfunc) == SIG_ERR) /* KILL and STOP */ warn("Trying to handle %d failed", i); for (;;) sleep(1000); return 0; } From owner-freebsd-threads@FreeBSD.ORG Thu Jun 8 21:30:06 2006 Return-Path: X-Original-To: threads@freebsd.org Delivered-To: freebsd-threads@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 93E3516CE63 for ; Thu, 8 Jun 2006 17:43:51 +0000 (UTC) (envelope-from maxim@macomnet.ru) Received: from mp2.macomnet.net (mp2.macomnet.net [195.128.64.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id F066043D45 for ; Thu, 8 Jun 2006 17:43:50 +0000 (GMT) (envelope-from maxim@macomnet.ru) Received: from localhost (localhost [127.0.0.1]) by mp2.macomnet.net (8.13.4/8.13.3) with ESMTP id k58HhgjO018437; Thu, 8 Jun 2006 21:43:42 +0400 (MSD) (envelope-from maxim@macomnet.ru) Date: Thu, 8 Jun 2006 21:43:42 +0400 (MSD) From: Maxim Konovalov To: Mikhail Teterin In-Reply-To: <200606081218.17131.mi+mx@aldan.algebra.com> Message-ID: <20060608213618.O17062@mp2.macomnet.net> References: <200606071906.25776.mi+mx@aldan.algebra.com> <200606071916.38538.mi+mx@aldan.algebra.com> <20060608081626.X6097@mp2.macomnet.net> <200606081218.17131.mi+mx@aldan.algebra.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=koi8-r Content-Transfer-Encoding: 8BIT Cc: threads@freebsd.org Subject: Re: SIGINFO and pthreads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jun 2006 21:30:06 -0000 On Thu, 8 Jun 2006, 12:18-0400, Mikhail Teterin wrote: > ÞÅÔ×ÅÒ 08 ÞÅÒ×ÅÎØ 2006 00:17, Maxim Konovalov ÎÁÐÉÓÁ×: > > Inline it if it's small. šMailman strips most attachments. > > Damn... Yes, it is small -- this is just a demo program. Compile it first as > > cc -o t t.c > > Then -- run and try various keyboard signals like Ctrl-C, Ctrl-Z, > Ctrl-T (SIGINFO), or Ctrl-\. (It will not quit on its own, you'll > have to kill it from another prompt.) > > They will all work. Then -- recompile as > > cc -o t -pthread t.c > > And run... This time around it will ignore the Ctrl-T, while > continuing to respond to others. > > > libpthread uses SIGINFO for dumping thread information to a file but > > looking over the code it seems it does allow to use SIGINFO to the > > app. > > I'd like to be able to disable the debugging feature or, at least, > force it to call my signal-handler AS EXPECTED AND DOCUMENTED, after > it is done with its own dumping. A funny thing your test program does work if you run it as LIBPTHREAD_DEBUG=yes ./t Try this patch: Index: thread/thr_sigaction.c =================================================================== RCS file: /home/ncvs/src/lib/libpthread/thread/thr_sigaction.c,v retrieving revision 1.23 diff -u -p -r1.23 thr_sigaction.c --- thread/thr_sigaction.c 13 Mar 2006 00:59:51 -0000 1.23 +++ thread/thr_sigaction.c 8 Jun 2006 17:30:31 -0000 @@ -75,7 +75,7 @@ _sigaction(int sig, const struct sigacti * Check if the kernel needs to be advised of a change * in signal action: */ - if (act != NULL && sig != SIGINFO) { + if (act != NULL /* && sig != SIGINFO */) { newact.sa_flags |= SA_SIGINFO; %%% For the first glance and quick test this check is not needed as we dump threads in already installed for SIGINFO _thr_sig_handler(). Of course we need our libpthreads experts review. -- Maxim Konovalov From owner-freebsd-threads@FreeBSD.ORG Thu Jun 8 22:52:34 2006 Return-Path: X-Original-To: threads@freebsd.org Delivered-To: freebsd-threads@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 58C3316A419 for ; Thu, 8 Jun 2006 22:52:34 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2610643D58 for ; Thu, 8 Jun 2006 22:52:32 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.6/8.13.6/NETPLEX) with ESMTP id k58MqPxq020478; Thu, 8 Jun 2006 18:52:25 -0400 (EDT) Date: Thu, 8 Jun 2006 18:52:25 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Maxim Konovalov In-Reply-To: <20060608213618.O17062@mp2.macomnet.net> Message-ID: References: <200606071906.25776.mi+mx@aldan.algebra.com> <200606071916.38538.mi+mx@aldan.algebra.com> <20060608081626.X6097@mp2.macomnet.net> <200606081218.17131.mi+mx@aldan.algebra.com> <20060608213618.O17062@mp2.macomnet.net> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-559023410-684387517-1149807145=:6968" X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) Cc: threads@freebsd.org, Mikhail Teterin Subject: Re: SIGINFO and pthreads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jun 2006 22:52:34 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---559023410-684387517-1149807145=:6968 Content-Type: TEXT/PLAIN; charset=koi8-r; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Thu, 8 Jun 2006, Maxim Konovalov wrote: > On Thu, 8 Jun 2006, 12:18-0400, Mikhail Teterin wrote: > >> =DE=C5=D4=D7=C5=D2 08 =DE=C5=D2=D7=C5=CE=D8 2006 00:17, Maxim Konovalov = =CE=C1=D0=C9=D3=C1=D7: >>> Inline it if it's small. =9AMailman strips most attachments. >> >> Damn... Yes, it is small -- this is just a demo program. Compile it firs= t as >> >> =09cc -o t t.c >> >> Then -- run and try various keyboard signals like Ctrl-C, Ctrl-Z, >> Ctrl-T (SIGINFO), or Ctrl-\. (It will not quit on its own, you'll >> have to kill it from another prompt.) >> >> They will all work. Then -- recompile as >> >> =09cc -o t -pthread t.c >> >> And run... This time around it will ignore the Ctrl-T, while >> continuing to respond to others. >> >>> libpthread uses SIGINFO for dumping thread information to a file but >>> looking over the code it seems it does allow to use SIGINFO to the >>> app. >> >> I'd like to be able to disable the debugging feature or, at least, >> force it to call my signal-handler AS EXPECTED AND DOCUMENTED, after >> it is done with its own dumping. > > A funny thing your test program does work if you run it as > > LIBPTHREAD_DEBUG=3Dyes ./t > > Try this patch: [ ... ] > For the first glance and quick test this check is not needed as we > dump threads in already installed for SIGINFO _thr_sig_handler(). Of > course we need our libpthreads experts review. Yes, that is a correct patch (remove the commented out section). Please go ahead and commit! --=20 DE ---559023410-684387517-1149807145=:6968-- From owner-freebsd-threads@FreeBSD.ORG Fri Jun 9 12:45:17 2006 Return-Path: X-Original-To: threads@freebsd.org Delivered-To: freebsd-threads@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D201116A419; Fri, 9 Jun 2006 12:45:17 +0000 (UTC) (envelope-from maxim@macomnet.ru) Received: from mp2.macomnet.net (mp2.macomnet.net [195.128.64.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5BF9043D73; Fri, 9 Jun 2006 12:45:17 +0000 (GMT) (envelope-from maxim@macomnet.ru) Received: from localhost (localhost [127.0.0.1]) by mp2.macomnet.net (8.13.4/8.13.3) with ESMTP id k59Cj6Ro049173; Fri, 9 Jun 2006 16:45:07 +0400 (MSD) (envelope-from maxim@macomnet.ru) Date: Fri, 9 Jun 2006 16:45:06 +0400 (MSD) From: Maxim Konovalov To: Daniel Eischen In-Reply-To: Message-ID: <20060609164120.X11643@mp2.macomnet.net> References: <200606071906.25776.mi+mx@aldan.algebra.com> <200606071916.38538.mi+mx@aldan.algebra.com> <20060608081626.X6097@mp2.macomnet.net> <200606081218.17131.mi+mx@aldan.algebra.com> <20060608213618.O17062@mp2.macomnet.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=KOI8-R Content-Transfer-Encoding: 8BIT Cc: threads@freebsd.org, Mikhail Teterin Subject: Re: SIGINFO and pthreads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jun 2006 12:45:18 -0000 Daniel, On Thu, 8 Jun 2006, 18:52-0400, Daniel Eischen wrote: > On Thu, 8 Jun 2006, Maxim Konovalov wrote: > > > On Thu, 8 Jun 2006, 12:18-0400, Mikhail Teterin wrote: > > > > > ÞÅÔ×ÅÒ 08 ÞÅÒ×ÅÎØ 2006 00:17, Maxim Konovalov ÎÁÐÉÓÁ×: > > > > Inline it if it's small. šMailman strips most attachments. > > > > > > Damn... Yes, it is small -- this is just a demo program. Compile it first > > > as > > > > > > cc -o t t.c > > > > > > Then -- run and try various keyboard signals like Ctrl-C, Ctrl-Z, > > > Ctrl-T (SIGINFO), or Ctrl-\. (It will not quit on its own, you'll > > > have to kill it from another prompt.) > > > > > > They will all work. Then -- recompile as > > > > > > cc -o t -pthread t.c > > > > > > And run... This time around it will ignore the Ctrl-T, while > > > continuing to respond to others. > > > > > > > libpthread uses SIGINFO for dumping thread information to a file but > > > > looking over the code it seems it does allow to use SIGINFO to the > > > > app. > > > > > > I'd like to be able to disable the debugging feature or, at least, > > > force it to call my signal-handler AS EXPECTED AND DOCUMENTED, after > > > it is done with its own dumping. > > > > A funny thing your test program does work if you run it as > > > > LIBPTHREAD_DEBUG=yes ./t > > > > Try this patch: > > [ ... ] > > > For the first glance and quick test this check is not needed as we > > dump threads in already installed for SIGINFO _thr_sig_handler(). Of > > course we need our libpthreads experts review. > > Yes, that is a correct patch (remove the commented out section). > Please go ahead and commit! There is still a problem if user decided to SIG_IGN or SIG_DFL SIGINFO. In this case threads dump stops working. I don't know how important this fuctionality is so here is a more aggressive patch: Index: thread/thr_private.h =================================================================== RCS file: /home/ncvs/src/lib/libpthread/thread/thr_private.h,v retrieving revision 1.126 diff -u -p -r1.126 thr_private.h --- thread/thr_private.h 29 Mar 2006 05:38:19 -0000 1.126 +++ thread/thr_private.h 9 Jun 2006 12:17:51 -0000 @@ -1317,4 +1317,11 @@ int __sys_poll(struct pollfd *, unsigne int __sys_msync(void *, size_t, int); #endif +static __inline int +_thr_dump_enabled(void) +{ + + return ((_thr_debug_flags & DBG_INFO_DUMP) != 0); +} + #endif /* !_THR_PRIVATE_H */ Index: thread/thr_sig.c =================================================================== RCS file: /home/ncvs/src/lib/libpthread/thread/thr_sig.c,v retrieving revision 1.84 diff -u -p -r1.84 thr_sig.c --- thread/thr_sig.c 6 Mar 2006 05:02:28 -0000 1.84 +++ thread/thr_sig.c 9 Jun 2006 12:18:15 -0000 @@ -98,12 +98,6 @@ static int sigproptbl[NSIG] = { #define DBG_MSG(x...) #endif -static __inline int -_thr_dump_enabled(void) -{ - return ((_thr_debug_flags & DBG_INFO_DUMP) != 0); -} - /* * Signal setup and delivery. * Index: thread/thr_sigaction.c =================================================================== RCS file: /home/ncvs/src/lib/libpthread/thread/thr_sigaction.c,v retrieving revision 1.23 diff -u -p -r1.23 thr_sigaction.c --- thread/thr_sigaction.c 13 Mar 2006 00:59:51 -0000 1.23 +++ thread/thr_sigaction.c 9 Jun 2006 12:40:31 -0000 @@ -75,7 +75,7 @@ _sigaction(int sig, const struct sigacti * Check if the kernel needs to be advised of a change * in signal action: */ - if (act != NULL && sig != SIGINFO) { + if (act != NULL) { newact.sa_flags |= SA_SIGINFO; @@ -91,6 +91,16 @@ _sigaction(int sig, const struct sigacti */ newact.sa_handler = (void (*) ())_thr_sig_handler; } + /* + * Install libpthread signal handler wrapper + * for SIGINFO signal if threads dump enabled + * even if a user set the signal handler to + * SIG_DFL or SIG_IGN. + */ + if (sig == SIGINFO && _thr_dump_enabled()) { + newact.sa_handler = + (void (*) ())_thr_sig_handler; + } /* Change the signal action in the kernel: */ if (__sys_sigaction(sig, &newact, NULL) != 0) { _thread_sigact[sig - 1] = oldact; %%% -- Maxim Konovalov From owner-freebsd-threads@FreeBSD.ORG Fri Jun 9 13:47:52 2006 Return-Path: X-Original-To: threads@freebsd.org Delivered-To: freebsd-threads@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4650416A41A for ; Fri, 9 Jun 2006 13:47:52 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id ACAAF43D73 for ; Fri, 9 Jun 2006 13:47:51 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.6/8.13.6/NETPLEX) with ESMTP id k59DlhJu005964; Fri, 9 Jun 2006 09:47:44 -0400 (EDT) Date: Fri, 9 Jun 2006 09:47:43 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Maxim Konovalov In-Reply-To: <20060609164120.X11643@mp2.macomnet.net> Message-ID: References: <200606071906.25776.mi+mx@aldan.algebra.com> <200606071916.38538.mi+mx@aldan.algebra.com> <20060608081626.X6097@mp2.macomnet.net> <200606081218.17131.mi+mx@aldan.algebra.com> <20060608213618.O17062@mp2.macomnet.net> <20060609164120.X11643@mp2.macomnet.net> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-559023410-758783491-1149860863=:10705" X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) Cc: threads@freebsd.org, Mikhail Teterin Subject: Re: SIGINFO and pthreads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Jun 2006 13:47:52 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---559023410-758783491-1149860863=:10705 Content-Type: TEXT/PLAIN; charset=KOI8-R; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Fri, 9 Jun 2006, Maxim Konovalov wrote: > Daniel, > > On Thu, 8 Jun 2006, 18:52-0400, Daniel Eischen wrote: > >> On Thu, 8 Jun 2006, Maxim Konovalov wrote: >> >>> On Thu, 8 Jun 2006, 12:18-0400, Mikhail Teterin wrote: >>> >>>> =DE=C5=D4=D7=C5=D2 08 =DE=C5=D2=D7=C5=CE=D8 2006 00:17, Maxim Konovalo= v =CE=C1=D0=C9=D3=C1=D7: >>>>> Inline it if it's small. =9AMailman strips most attachments. >>>> >>>> Damn... Yes, it is small -- this is just a demo program. Compile it fi= rst >>>> as >>>> >>>> cc -o t t.c >>>> >>>> Then -- run and try various keyboard signals like Ctrl-C, Ctrl-Z, >>>> Ctrl-T (SIGINFO), or Ctrl-\. (It will not quit on its own, you'll >>>> have to kill it from another prompt.) >>>> >>>> They will all work. Then -- recompile as >>>> >>>> cc -o t -pthread t.c >>>> >>>> And run... This time around it will ignore the Ctrl-T, while >>>> continuing to respond to others. >>>> >>>>> libpthread uses SIGINFO for dumping thread information to a file but >>>>> looking over the code it seems it does allow to use SIGINFO to the >>>>> app. >>>> >>>> I'd like to be able to disable the debugging feature or, at least, >>>> force it to call my signal-handler AS EXPECTED AND DOCUMENTED, after >>>> it is done with its own dumping. >>> >>> A funny thing your test program does work if you run it as >>> >>> LIBPTHREAD_DEBUG=3Dyes ./t >>> >>> Try this patch: >> >> [ ... ] >> >>> For the first glance and quick test this check is not needed as we >>> dump threads in already installed for SIGINFO _thr_sig_handler(). Of >>> course we need our libpthreads experts review. >> >> Yes, that is a correct patch (remove the commented out section). >> Please go ahead and commit! > > There is still a problem if user decided to SIG_IGN or SIG_DFL > SIGINFO. In this case threads dump stops working. I don't know how > important this fuctionality is so here is a more aggressive patch: I could go either way on the issue. This second patch looks fine to me, so if you want to commit this one, that is fine with me. Thanks! --=20 DE ---559023410-758783491-1149860863=:10705--