From owner-freebsd-threads@FreeBSD.ORG Mon Jan 21 11:07:09 2008 Return-Path: Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 76B5516A4CA for ; Mon, 21 Jan 2008 11:07:09 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 6717413C4DD for ; Mon, 21 Jan 2008 11:07:09 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m0LB79sw047162 for ; Mon, 21 Jan 2008 11:07:09 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m0LB78qw047158 for freebsd-threads@FreeBSD.org; Mon, 21 Jan 2008 11:07:08 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 21 Jan 2008 11:07:08 GMT Message-Id: <200801211107.m0LB78qw047158@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-threads@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-threads@FreeBSD.org 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, 21 Jan 2008 11:07:09 -0000 Current FreeBSD problem reports Critical problems S Tracker Resp. Description -------------------------------------------------------------------------------- s threa/76690 threads fork hang in child for -lc_r 1 problem total. Serious problems S Tracker Resp. Description -------------------------------------------------------------------------------- s threa/24472 threads libc_r does not honor SO_SNDTIMEO/SO_RCVTIMEO socket o s threa/24632 threads libc_r delicate deviation from libc in handling SIGCHL s bin/32295 threads pthread dont dequeue signals s threa/34536 threads accept() blocks other threads f kern/38549 threads the procces compiled whith pthread stopped in pthread_ s threa/39922 threads [threads] [patch] Threaded applications executed with s threa/48856 threads Setting SIGCHLD to SIG_IGN still leaves zombies under s threa/49087 threads Signals lost in programs linked with libc_r o threa/70975 threads unexpected and unreliable behaviour when using SYSV se o threa/72953 threads fork() unblocks blocked signals w/o PTHREAD_SCOPE_SYST o threa/75273 threads FBSD 5.3 libpthread (KSE) bug o threa/75374 threads pthread_kill() ignores SA_SIGINFO flag s threa/76694 threads fork cause hang in dup()/close() function in child (-l o threa/79683 threads svctcp_create() fails if multiple threads call at the o threa/80435 threads panic on high loads o threa/83914 threads [libc] popen() doesn't work in static threaded program s threa/84483 threads problems with devel/nspr and -lc_r on 4.x s threa/94467 threads send(), sendto() and sendmsg() are not correct in libc s threa/100815 threads FBSD 5.5 broke nanosleep in libc_r o threa/101323 threads fork(2) in threaded programs broken. o threa/103975 threads Implicit loading/unloading of libpthread.so may crash o threa/110636 threads gdb(1): using gdb with multi thread application with l o threa/118715 threads kse problem 23 problems total. Non-critical problems S Tracker Resp. Description -------------------------------------------------------------------------------- s threa/30464 threads pthread mutex attributes -- pshared s threa/37676 threads libc_r: msgsnd(), msgrcv(), pread(), pwrite() need wra s threa/40671 threads pthread_cancel doesn't remove thread from condition qu s threa/69020 threads pthreads library leaks _gc_mutex o threa/79887 threads [patch] freopen() isn't thread-safe o threa/80992 threads abort() sometimes not caught by gdb depending on threa o threa/110306 threads apache 2.0 segmentation violation when calling gethost o threa/115211 threads pthread_atfork misbehaves in initial thread o threa/116181 threads /dev/io-related io access permissions are not propagat o threa/116668 threads can no longer use jdk15 with libthr on -stable SMP 10 problems total. From owner-freebsd-threads@FreeBSD.ORG Wed Jan 23 10:30:02 2008 Return-Path: Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AB73816A46E for ; Wed, 23 Jan 2008 10:30:02 +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 7F15413C4CE for ; Wed, 23 Jan 2008 10:30:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m0NAU26e002555 for ; Wed, 23 Jan 2008 10:30:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m0NAU2w6002554; Wed, 23 Jan 2008 10:30:02 GMT (envelope-from gnats) Resent-Date: Wed, 23 Jan 2008 10:30:02 GMT Resent-Message-Id: <200801231030.m0NAU2w6002554@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-threads@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Bernard Buri Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C901F16A468 for ; Wed, 23 Jan 2008 10:26:53 +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 B242B13C4CE for ; Wed, 23 Jan 2008 10:26:53 +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 m0NAPK45088571 for ; Wed, 23 Jan 2008 10:25:20 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.2/8.14.1/Submit) id m0NAPK69088569; Wed, 23 Jan 2008 10:25:20 GMT (envelope-from nobody) Message-Id: <200801231025.m0NAPK69088569@www.freebsd.org> Date: Wed, 23 Jan 2008 10:25:20 GMT From: Bernard Buri To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: threads/119920: fork broken in libpthread 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: Wed, 23 Jan 2008 10:30:02 -0000 >Number: 119920 >Category: threads >Synopsis: fork broken in libpthread >Confidential: no >Severity: critical >Priority: medium >Responsible: freebsd-threads >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Jan 23 10:30:02 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Bernard Buri >Release: 6.3-RELEASE >Organization: ask! >Environment: FreeBSD host.domain 6.3-RELEASE FreeBSD 6.3-RELEASE #12: Mon Jan 21 13:23:06 CET 2008 root@host.domain:/usr/obj/usr/src/sys/SMP i386 >Description: Sometimes, when a multithreaded application tries to spawn another process, the child process loops with 100% CPU in the fork () procedure. Here is the backtrace after attaching gdb to the child process: #0 0x6809c198 in pthread_sigmask () from /lib/libpthread.so.2 #1 0x6809c148 in sigprocmask () from /lib/libpthread.so.2 #2 0x680a660c in pthread_mutexattr_init () from /lib/libpthread.so.2 #3 0x680992db in fork () from /lib/libpthread.so.2 #4 0x68ae735d in jdk_fork_wrapper () from /usr/local/jdk1.6.0/jre/lib/i386/libjava.so #5 0x68ae798c in Java_java_lang_UNIXProcess_forkAndExec () from /usr/local/jdk1.6.0/jre/lib/i386/libjava.so #6 0x68b1868e in ?? () #7 0x08a958ec in ?? () #8 0xbf1778a0 in ?? () .. >How-To-Repeat: Most of the time, the problem was observed with a java process, but also, after logging into a gnome session, there are sometimes processes running 100% CPU. I can regularly reproduce this behaviour with Eclipse CDT (C/C++ Development Tools). >Fix: The problem could not be observed with libthr. >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-threads@FreeBSD.ORG Thu Jan 24 08:50:03 2008 Return-Path: Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3940616A41A for ; Thu, 24 Jan 2008 08:50:03 +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 1465513C4F3 for ; Thu, 24 Jan 2008 08:50:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m0O8o29M023501 for ; Thu, 24 Jan 2008 08:50:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m0O8o2JQ023500; Thu, 24 Jan 2008 08:50:02 GMT (envelope-from gnats) Date: Thu, 24 Jan 2008 08:50:02 GMT Message-Id: <200801240850.m0O8o2JQ023500@freefall.freebsd.org> To: freebsd-threads@FreeBSD.org From: Gary Stanley Cc: Subject: Re: threads/119920: fork broken in libpthread X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Gary Stanley List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jan 2008 08:50:03 -0000 The following reply was made to PR threads/119920; it has been noted by GNATS. From: Gary Stanley To: bug-followup@FreeBSD.org Cc: Subject: Re: threads/119920: fork broken in libpthread Date: Thu, 24 Jan 2008 03:24:47 -0500 I also have this problem, see threads/118715 I was able to grab some ktrace info, but most of the time the process is stuck, and ktrace doesn't display any data. From owner-freebsd-threads@FreeBSD.ORG Thu Jan 24 09:11:42 2008 Return-Path: Delivered-To: freebsd-threads@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4CE8716A468 for ; Thu, 24 Jan 2008 09:11:42 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outU.internet-mail-service.net (outU.internet-mail-service.net [216.240.47.244]) by mx1.freebsd.org (Postfix) with ESMTP id 3964F13C4D9 for ; Thu, 24 Jan 2008 09:11:41 +0000 (UTC) (envelope-from julian@elischer.org) Received: from mx0.idiom.com (HELO idiom.com) (216.240.32.160) by out.internet-mail-service.net (qpsmtpd/0.40) with ESMTP; Thu, 24 Jan 2008 01:11:40 -0800 Received: from julian-mac.elischer.org (localhost [127.0.0.1]) by idiom.com (Postfix) with ESMTP id ECDB6126FCB; Thu, 24 Jan 2008 01:11:39 -0800 (PST) Message-ID: <4798564B.7070500@elischer.org> Date: Thu, 24 Jan 2008 01:11:39 -0800 From: Julian Elischer User-Agent: Thunderbird 2.0.0.9 (Macintosh/20071031) MIME-Version: 1.0 To: Gary Stanley References: <200801240850.m0O8o2JQ023500@freefall.freebsd.org> In-Reply-To: <200801240850.m0O8o2JQ023500@freefall.freebsd.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Daniel Eischen , freebsd-threads@FreeBSD.org Subject: Re: threads/119920: fork broken in libpthread 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, 24 Jan 2008 09:11:42 -0000 Gary Stanley wrote: > The following reply was made to PR threads/119920; it has been noted by GNATS. > > From: Gary Stanley > To: bug-followup@FreeBSD.org > Cc: > Subject: Re: threads/119920: fork broken in libpthread > Date: Thu, 24 Jan 2008 03:24:47 -0500 > > I also have this problem, see threads/118715 > > I was able to grab some ktrace info, but most of the time the process > is stuck, and ktrace doesn't display any data. > > _______________________________________________ > freebsd-threads@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-threads > To unsubscribe, send any mail to "freebsd-threads-unsubscribe@freebsd.org" dan what IS the fix for this? I assume you must have fixed it in -current/7 what was YOUR fix alfred? From owner-freebsd-threads@FreeBSD.ORG Thu Jan 24 15:08:21 2008 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0CB6216A469; Thu, 24 Jan 2008 15:08:21 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 9D93413C4CC; Thu, 24 Jan 2008 15:08:20 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.2/8.14.2/NETPLEX) with ESMTP id m0OF8Gjp017323; Thu, 24 Jan 2008 10:08:16 -0500 (EST) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.0 (mail.netplex.net [204.213.176.10]); Thu, 24 Jan 2008 10:08:17 -0500 (EST) Date: Thu, 24 Jan 2008 10:08:16 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Julian Elischer In-Reply-To: <4798564B.7070500@elischer.org> Message-ID: References: <200801240850.m0O8o2JQ023500@freefall.freebsd.org> <4798564B.7070500@elischer.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Gary Stanley , freebsd-threads@freebsd.org Subject: Re: threads/119920: fork broken in libpthread 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, 24 Jan 2008 15:08:21 -0000 On Thu, 24 Jan 2008, Julian Elischer wrote: > Gary Stanley wrote: >> The following reply was made to PR threads/119920; it has been noted by >> GNATS. >> >> From: Gary Stanley >> To: bug-followup@FreeBSD.org >> Cc: Subject: Re: threads/119920: fork broken in libpthread >> Date: Thu, 24 Jan 2008 03:24:47 -0500 >> >> I also have this problem, see threads/118715 >> I was able to grab some ktrace info, but most of the time the process is >> stuck, and ktrace doesn't display any data. >> _______________________________________________ >> freebsd-threads@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-threads >> To unsubscribe, send any mail to "freebsd-threads-unsubscribe@freebsd.org" > > dan what IS the fix for this? I assume you must have fixed it in -current/7 You want cvs diff -u -r1.126 -r1.128 src/lib/libkse/thread/thr_kern.c. The WARNS'ify diffs are not necessary, so it should look something like shown below. Probably an MFC of all of libkse (minus jasone's malloc changes) should be done to -7 and -6. -- DE Index: thr_kern.c =================================================================== RCS file: /opt/FreeBSD/cvs/src/lib/libkse/thread/thr_kern.c,v retrieving revision 1.126 retrieving revision 1.128 diff -u -r1.126 -r1.128 --- thr_kern.c 27 Nov 2007 03:16:44 -0000 1.126 +++ thr_kern.c 6 Dec 2007 06:04:01 -0000 1.128 @@ -342,6 +342,16 @@ _LCK_SET_PRIVATE2(&curthread->kse->k_lockusers[i], NULL); } curthread->kse->k_locklevel = 0; + + /* + * Reinitialize the thread and signal locks so that + * sigaction() will work after a fork(). + */ + _lock_reinit(&curthread->lock, LCK_ADAPTIVE, _thr_lock_wait, + _thr_lock_wakeup); + _lock_reinit(&_thread_signal_lock, LCK_ADAPTIVE, _kse_lock_wait, + _kse_lock_wakeup); + _thr_spinlock_init(); if (__isthreaded) { _thr_rtld_fini(); @@ -351,6 +361,19 @@ curthread->kse->k_kcb->kcb_kmbx.km_curthread = NULL; curthread->attr.flags |= PTHREAD_SCOPE_SYSTEM; + /* + * After a fork, it is possible that an upcall occurs in + * the parent KSE that fork()'d before the child process + * is fully created and before its vm space is copied. + * During the upcall, the tcb is set to null or to another + * thread, and this is what gets copied in the child process + * when the vm space is cloned sometime after the upcall + * occurs. Note that we shouldn't have to set the kcb, but + * we do it for completeness. + */ + _kcb_set(curthread->kse->k_kcb); + _tcb_set(curthread->kse->k_kcb, curthread->tcb); + /* After a fork(), there child should have no pending signals. */ sigemptyset(&curthread->sigpend); From owner-freebsd-threads@FreeBSD.ORG Thu Jan 24 15:13:15 2008 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 477E516A41A for ; Thu, 24 Jan 2008 15:13:15 +0000 (UTC) (envelope-from jasone@freebsd.org) Received: from canonware.com (canonware.com [64.183.146.166]) by mx1.freebsd.org (Postfix) with ESMTP id 18E3913C4E3 for ; Thu, 24 Jan 2008 15:13:15 +0000 (UTC) (envelope-from jasone@freebsd.org) Received: from [192.168.168.201] (unknown [192.168.168.201]) by canonware.com (Postfix) with ESMTP id B81A61298C5; Thu, 24 Jan 2008 07:13:39 -0800 (PST) Message-ID: <4798AB10.5090208@freebsd.org> Date: Thu, 24 Jan 2008 07:13:20 -0800 From: Jason Evans User-Agent: Thunderbird 1.5.0.12 (X11/20071129) MIME-Version: 1.0 To: Daniel Eischen References: <200801240850.m0O8o2JQ023500@freefall.freebsd.org> <4798564B.7070500@elischer.org> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Gary Stanley , Julian Elischer , freebsd-threads@freebsd.org Subject: Re: threads/119920: fork broken in libpthread 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, 24 Jan 2008 15:13:15 -0000 Daniel Eischen wrote: > You want cvs diff -u -r1.126 -r1.128 src/lib/libkse/thread/thr_kern.c. > The WARNS'ify diffs are not necessary, so it should look something > like shown below. Probably an MFC of all of libkse (minus jasone's > malloc changes) should be done to -7 and -6. I want to MFC malloc before the 7.1 release, so if you're MFCing the threads libraries, please include the malloc-related changes as well. Thanks, Jason From owner-freebsd-threads@FreeBSD.ORG Thu Jan 24 22:27:37 2008 Return-Path: Delivered-To: freebsd-threads@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7521916A418; Thu, 24 Jan 2008 22:27:37 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id 5F91A13C45D; Thu, 24 Jan 2008 22:27:37 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id EFCBF1A4D82; Thu, 24 Jan 2008 14:23:39 -0800 (PST) Date: Thu, 24 Jan 2008 14:23:39 -0800 From: Alfred Perlstein To: Julian Elischer Message-ID: <20080124222339.GT99258@elvis.mu.org> References: <200801240850.m0O8o2JQ023500@freefall.freebsd.org> <4798564B.7070500@elischer.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="L2Brqb15TUChFOBK" Content-Disposition: inline In-Reply-To: <4798564B.7070500@elischer.org> User-Agent: Mutt/1.4.2.3i Cc: Daniel Eischen , Gary Stanley , freebsd-threads@FreeBSD.org Subject: Re: threads/119920: fork broken in libpthread 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, 24 Jan 2008 22:27:37 -0000 --L2Brqb15TUChFOBK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline * Julian Elischer [080124 01:17] wrote: > Gary Stanley wrote: > >The following reply was made to PR threads/119920; it has been noted by > >GNATS. > > > >From: Gary Stanley > >To: bug-followup@FreeBSD.org > >Cc: > >Subject: Re: threads/119920: fork broken in libpthread > >Date: Thu, 24 Jan 2008 03:24:47 -0500 > > > > I also have this problem, see threads/118715 > > > > I was able to grab some ktrace info, but most of the time the process > > is stuck, and ktrace doesn't display any data. > > > >_______________________________________________ > >freebsd-threads@freebsd.org mailing list > >http://lists.freebsd.org/mailman/listinfo/freebsd-threads > >To unsubscribe, send any mail to "freebsd-threads-unsubscribe@freebsd.org" > > dan what IS the fix for this? I assume you must have fixed it in > -current/7 > > what was YOUR fix alfred? Attached. -- - Alfred Perlstein --L2Brqb15TUChFOBK Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="thr_fork.diff" Index: thr_fork.c =================================================================== RCS file: /home/ncvs/src/lib/libpthread/thread/Attic/thr_fork.c,v retrieving revision 1.35 diff -u -r1.35 thr_fork.c --- thr_fork.c 18 Dec 2004 18:07:37 -0000 1.35 +++ thr_fork.c 29 Oct 2007 05:25:32 -0000 @@ -93,7 +93,10 @@ if (_kse_isthreaded() != 0) { _spinlock(__malloc_lock); } - if ((ret = __sys_fork()) == 0) { + THR_SCHED_LOCK(curthread, curthread); + ret = __sys_fork(); + THR_SCHED_UNLOCK(curthread, curthread); + if (ret == 0) { /* Child process */ errsave = errno; --L2Brqb15TUChFOBK-- From owner-freebsd-threads@FreeBSD.ORG Thu Jan 24 22:32:55 2008 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17AE816A419; Thu, 24 Jan 2008 22:32:55 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id D8EF113C467; Thu, 24 Jan 2008 22:32:54 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.2/8.14.2/NETPLEX) with ESMTP id m0OMWqDM022564; Thu, 24 Jan 2008 17:32:52 -0500 (EST) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.0 (mail.netplex.net [204.213.176.10]); Thu, 24 Jan 2008 17:32:52 -0500 (EST) Date: Thu, 24 Jan 2008 17:32:51 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Alfred Perlstein In-Reply-To: <20080124222339.GT99258@elvis.mu.org> Message-ID: References: <200801240850.m0O8o2JQ023500@freefall.freebsd.org> <4798564B.7070500@elischer.org> <20080124222339.GT99258@elvis.mu.org> MIME-Version: 1.0 Content-Type: MULTIPART/Mixed; boundary=L2Brqb15TUChFOBK Content-ID: Content-Disposition: inline Cc: Gary Stanley , Julian Elischer , freebsd-threads@freebsd.org Subject: Re: threads/119920: fork broken in libpthread 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, 24 Jan 2008 22:32:55 -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. --L2Brqb15TUChFOBK Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Content-ID: Content-Disposition: inline On Thu, 24 Jan 2008, Alfred Perlstein wrote: > * Julian Elischer [080124 01:17] wrote: >> Gary Stanley wrote: >>> The following reply was made to PR threads/119920; it has been noted by >>> GNATS. >>> >>> From: Gary Stanley >>> To: bug-followup@FreeBSD.org >>> Cc: >>> Subject: Re: threads/119920: fork broken in libpthread >>> Date: Thu, 24 Jan 2008 03:24:47 -0500 >>> >>> I also have this problem, see threads/118715 >>> >>> I was able to grab some ktrace info, but most of the time the process >>> is stuck, and ktrace doesn't display any data. >>> >>> _______________________________________________ >>> freebsd-threads@freebsd.org mailing list >>> http://lists.freebsd.org/mailman/listinfo/freebsd-threads >>> To unsubscribe, send any mail to "freebsd-threads-unsubscribe@freebsd.org" >> >> dan what IS the fix for this? I assume you must have fixed it in >> -current/7 >> >> what was YOUR fix alfred? > > Attached. Which isn't a correct fix, BTW. It is possible that the unlock can try to give the lock to a non-existent thread. -- DE --L2Brqb15TUChFOBK Content-Type: TEXT/X-DIFF; charset=us-ascii Content-Transfer-Encoding: QUOTED-PRINTABLE Content-ID: Content-Description: Content-Disposition: attachment; filename=thr_fork.diff Index: thr_fork.c=0D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0D RCS file: /home/ncvs/src/lib/libpthread/thread/Attic/thr_fork.c,v=0D retrieving revision 1.35=0D diff -u -r1.35 thr_fork.c=0D --- thr_fork.c=0918 Dec 2004 18:07:37 -0000=091.35=0D +++ thr_fork.c=0929 Oct 2007 05:25:32 -0000=0D @@ -93,7 +93,10 @@=0D =09if (_kse_isthreaded() !=3D 0) {=0D =09=09_spinlock(__malloc_lock);=0D =09}=0D -=09if ((ret =3D __sys_fork()) =3D=3D 0) {=0D +=09THR_SCHED_LOCK(curthread, curthread);=0D +=09ret =3D __sys_fork();=0D +=09THR_SCHED_UNLOCK(curthread, curthread);=0D +=09if (ret =3D=3D 0) {=0D =09=09/* Child process */=0D =09=09errsave =3D errno;=20=0D =20=0D =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00= =00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00 --L2Brqb15TUChFOBK-- From owner-freebsd-threads@FreeBSD.ORG Thu Jan 24 22:35:30 2008 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E0D8416A417; Thu, 24 Jan 2008 22:35:30 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id CC17013C469; Thu, 24 Jan 2008 22:35:30 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id 635F21A4D83; Thu, 24 Jan 2008 14:31:33 -0800 (PST) Date: Thu, 24 Jan 2008 14:31:33 -0800 From: Alfred Perlstein To: Daniel Eischen Message-ID: <20080124223133.GU99258@elvis.mu.org> References: <200801240850.m0O8o2JQ023500@freefall.freebsd.org> <4798564B.7070500@elischer.org> <20080124222339.GT99258@elvis.mu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Cc: Gary Stanley , Julian Elischer , freebsd-threads@freebsd.org Subject: Re: threads/119920: fork broken in libpthread 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, 24 Jan 2008 22:35:31 -0000 * Daniel Eischen [080124 14:28] wrote: > On Thu, 24 Jan 2008, Alfred Perlstein wrote: > > >* Julian Elischer [080124 01:17] wrote: > >>Gary Stanley wrote: > >>>The following reply was made to PR threads/119920; it has been noted by > >>>GNATS. > >>> > >>>From: Gary Stanley > >>>To: bug-followup@FreeBSD.org > >>>Cc: > >>>Subject: Re: threads/119920: fork broken in libpthread > >>>Date: Thu, 24 Jan 2008 03:24:47 -0500 > >>> > >>>I also have this problem, see threads/118715 > >>> > >>>I was able to grab some ktrace info, but most of the time the process > >>>is stuck, and ktrace doesn't display any data. > >>> > >>>_______________________________________________ > >>>freebsd-threads@freebsd.org mailing list > >>>http://lists.freebsd.org/mailman/listinfo/freebsd-threads > >>>To unsubscribe, send any mail to > >>>"freebsd-threads-unsubscribe@freebsd.org" > >> > >>dan what IS the fix for this? I assume you must have fixed it in > >>-current/7 > >> > >>what was YOUR fix alfred? > > > >Attached. > > Which isn't a correct fix, BTW. It is possible that the unlock > can try to give the lock to a non-existent thread. Yes, I understand that problem, but it's not clear to my why/how it can happen. I guess because another thread could put itself on the "blocked queue" for that lock? Is there a way to prevent that or to clear the lock afterward? -Alfred From owner-freebsd-threads@FreeBSD.ORG Thu Jan 24 22:38:51 2008 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B96716A41B; Thu, 24 Jan 2008 22:38:51 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 0135113C4D3; Thu, 24 Jan 2008 22:38:50 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.2/8.14.2/NETPLEX) with ESMTP id m0OMcmrL026514; Thu, 24 Jan 2008 17:38:48 -0500 (EST) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.0 (mail.netplex.net [204.213.176.10]); Thu, 24 Jan 2008 17:38:48 -0500 (EST) Date: Thu, 24 Jan 2008 17:38:48 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Alfred Perlstein In-Reply-To: <20080124223133.GU99258@elvis.mu.org> Message-ID: References: <200801240850.m0O8o2JQ023500@freefall.freebsd.org> <4798564B.7070500@elischer.org> <20080124222339.GT99258@elvis.mu.org> <20080124223133.GU99258@elvis.mu.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Gary Stanley , Julian Elischer , freebsd-threads@freebsd.org Subject: Re: threads/119920: fork broken in libpthread 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, 24 Jan 2008 22:38:51 -0000 On Thu, 24 Jan 2008, Alfred Perlstein wrote: > * Daniel Eischen [080124 14:28] wrote: >> On Thu, 24 Jan 2008, Alfred Perlstein wrote: >> >>> * Julian Elischer [080124 01:17] wrote: >>>> Gary Stanley wrote: >>>>> The following reply was made to PR threads/119920; it has been noted by >>>>> GNATS. >>>>> >>>>> From: Gary Stanley >>>>> To: bug-followup@FreeBSD.org >>>>> Cc: >>>>> Subject: Re: threads/119920: fork broken in libpthread >>>>> Date: Thu, 24 Jan 2008 03:24:47 -0500 >>>>> >>>>> I also have this problem, see threads/118715 >>>>> >>>>> I was able to grab some ktrace info, but most of the time the process >>>>> is stuck, and ktrace doesn't display any data. >>>>> >>>>> _______________________________________________ >>>>> freebsd-threads@freebsd.org mailing list >>>>> http://lists.freebsd.org/mailman/listinfo/freebsd-threads >>>>> To unsubscribe, send any mail to >>>>> "freebsd-threads-unsubscribe@freebsd.org" >>>> >>>> dan what IS the fix for this? I assume you must have fixed it in >>>> -current/7 >>>> >>>> what was YOUR fix alfred? >>> >>> Attached. >> >> Which isn't a correct fix, BTW. It is possible that the unlock >> can try to give the lock to a non-existent thread. > > Yes, I understand that problem, but it's not clear to my why/how it can happen. > > I guess because another thread could put itself on the "blocked queue" > for that lock? Is there a way to prevent that or to clear the lock > afterward? Well, you don't have to worry about this if you use my fix. The thread locks are reinitialized and the KCB and TCB are reset after the fork. -- DE From owner-freebsd-threads@FreeBSD.ORG Fri Jan 25 11:00:05 2008 Return-Path: Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7053116A418 for ; Fri, 25 Jan 2008 11:00:05 +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 6992B13C447 for ; Fri, 25 Jan 2008 11:00:05 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m0PB05RP043839 for ; Fri, 25 Jan 2008 11:00:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m0PB05sM043838; Fri, 25 Jan 2008 11:00:05 GMT (envelope-from gnats) Date: Fri, 25 Jan 2008 11:00:05 GMT Message-Id: <200801251100.m0PB05sM043838@freefall.freebsd.org> To: freebsd-threads@FreeBSD.org From: Gary Stanley Cc: Subject: Re: threads/119920: fork broken in libpthread X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Gary Stanley List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jan 2008 11:00:05 -0000 The following reply was made to PR threads/119920; it has been noted by GNATS. From: Gary Stanley To: bug-followup@FreeBSD.org Cc: Subject: Re: threads/119920: fork broken in libpthread Date: Fri, 25 Jan 2008 05:50:28 -0500 Can you try this patch? I ported it from some mail regarding this issue on threads@ diff -ur lib/libpthread/thread/thr_kern.c lib/libpthread/thread/thr_kern.c --- lib/libpthread/thread/thr_kern.c 2006-03-16 23:29:07.000000000 +0000 +++ lib/libpthread/thread/thr_kern.c 2008-01-25 10:33:23.000000000 +0000 @@ -345,6 +345,17 @@ _LCK_SET_PRIVATE2(&curthread->kse->k_lockusers[i], NULL); } curthread->kse->k_locklevel = 0; + + /* + * Reinitialize the thread and signal locks so that + * sigaction() will work after a fork(). + */ + _lock_reinit(&curthread->lock, LCK_ADAPTIVE, _thr_lock_wait, + _thr_lock_wakeup); + _lock_reinit(&_thread_signal_lock, LCK_ADAPTIVE, _kse_lock_wait, + _kse_lock_wakeup); + + _thr_spinlock_init(); if (__isthreaded) { _thr_rtld_fini(); @@ -354,6 +365,20 @@ curthread->kse->k_kcb->kcb_kmbx.km_curthread = NULL; curthread->attr.flags |= PTHREAD_SCOPE_SYSTEM; + /* + * After a fork, it is possible that an upcall occurs in + * the parent KSE that fork()'d before the child process + * is fully created and before its vm space is copied. + * During the upcall, the tcb is set to null or to another + * thread, and this is what gets copied in the child process + * when the vm space is cloned sometime after the upcall + * occurs. Note that we shouldn't have to set the kcb, but + * we do it for completeness. + */ + _kcb_set(curthread->kse->k_kcb); + _tcb_set(curthread->kse->k_kcb, curthread->tcb); + + /* After a fork(), there child should have no pending signals. */ sigemptyset(&curthread->sigpend);