From owner-freebsd-threads@FreeBSD.ORG Sun Aug 5 09:40:02 2007 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 0C80D16A420 for ; Sun, 5 Aug 2007 09:40: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 E0F7513C4DD for ; Sun, 5 Aug 2007 09:40:01 +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 l759e1mw010394 for ; Sun, 5 Aug 2007 09:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l759e1cM010393; Sun, 5 Aug 2007 09:40:01 GMT (envelope-from gnats) Resent-Date: Sun, 5 Aug 2007 09:40:01 GMT Resent-Message-Id: <200708050940.l759e1cM010393@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, Douglas Wells Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C5BD216A417 for ; Sun, 5 Aug 2007 09:35:00 +0000 (UTC) (envelope-from sysmaint@contek.com) Received: from smtp02.lnh.mail.rcn.net (smtp02.lnh.mail.rcn.net [207.172.157.102]) by mx1.freebsd.org (Postfix) with ESMTP id 96A1A13C474 for ; Sun, 5 Aug 2007 09:35:00 +0000 (UTC) (envelope-from sysmaint@contek.com) Received: from mr02.lnh.mail.rcn.net ([207.172.157.22]) by smtp02.lnh.mail.rcn.net with ESMTP; 05 Aug 2007 05:06:22 -0400 Received: from smtp01.lnh.mail.rcn.net (smtp01.lnh.mail.rcn.net [207.172.4.11]) by mr02.lnh.mail.rcn.net (MOS 3.8.3-GA) with ESMTP id NQC26144; Sun, 5 Aug 2007 05:06:13 -0400 (EDT) Received: from 207-172-216-217.s979.apx1.sbo.ma.dialup.rcn.com (HELO mail.contek.com) ([207.172.216.217]) by smtp01.lnh.mail.rcn.net with ESMTP; 05 Aug 2007 05:06:12 -0400 Received: by mail.contek.com (Postfix, from userid 10112) id 2646B3F407; Sun, 5 Aug 2007 01:50:17 -0400 (EDT) Message-Id: <20070805055017.2646B3F407@mail.contek.com> Date: Sun, 5 Aug 2007 01:50:17 -0400 (EDT) From: Douglas Wells To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: sysmaint@contek.com Subject: threads/115211: pthread_atfork misbehaves in initial thread X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Douglas Wells List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Aug 2007 09:40:02 -0000 >Number: 115211 >Category: threads >Synopsis: pthread_atfork misbehaves in initial thread >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-threads >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Aug 05 09:40:01 GMT 2007 >Closed-Date: >Last-Modified: >Originator: Douglas Wells >Release: FreeBSD 6.2-RELEASE-p1 i386 >Organization: >Environment: System: FreeBSD flame.contek.com 6.2-RELEASE-p1 FreeBSD 6.2-RELEASE-p1 #0: Sun Feb 11 18:14:07 EST 2007 root@flame.contek.com:/other5/src.6.2/sys/i386/compile/FLAME.6.2 i386 Above system is patched up to SA-07:07.bind. Using default compiler: gcc version 3.4.6 [FreeBSD] 20060305. >Description: If pthread_atfork is invoked in the original thread of a process, it does *not* invoke the various handlers. If the same test is invoked from a created thread, it invokes the various handlers as expected. I don't see any exception in the POSIX standard that supports this, and the test program runs as expected on a recent OS/X. >How-To-Repeat: Use the included test program. If compiled and run as: "gcc -pthread atforkbug.c && ./a.out", example (erroneous) output is: parent pid (11263) Child exiting: (11264) child (11264) returned If compiled and run as: "gcc -DUSE_NEW_THREAD -pthread atforkbug.c && ./a.out", the program behaves as I expect: parent pid (11270) af_prepare: pid (11270) af_parent: pid (11270) af_child: pid (11271) Child exiting: (11271) child (11271) returned ------------------------- test program ---------------------- #include #include #include #include #include #include #include #include #include #if defined (USE_NEW_THREAD) bool run_in_separate_thread = true; #else bool run_in_separate_thread = false; #endif void af_prepare (void) { fprintf (stderr, "af_prepare: pid (%ld)\n", (long) getpid ()); } void af_parent (void) { fprintf (stderr, " af_parent: pid (%ld)\n", (long) getpid ()); } void af_child (void) { fprintf (stderr, " af_child: pid (%ld)\n", (long) getpid ()); } void * run_test (void *arg) { pid_t child, xpid; int err; (void) arg; err = pthread_atfork (af_prepare, af_parent, af_child); assert (err == 0); switch ((int) (child = fork ())) { case -1: assert (! "bad fork"); case 0: /* child here */ sleep (1); fprintf (stderr, "Child exiting: (%ld)\n", (long) getpid ()); exit (EXIT_SUCCESS); default: xpid = waitpid (child, NULL, 0); assert (xpid == child); fprintf (stdout, "child (%ld) returned\n", (long) child); } return NULL; } int main (void) { fprintf (stdout, "parent pid (%ld)\n", (long) getpid ()); if (run_in_separate_thread) { pthread_t tid; int err; err = pthread_create (&tid, NULL, run_test, NULL); assert (err == 0); err = pthread_join (tid, NULL); assert (err == 0); } else run_test (NULL); return EXIT_SUCCESS; } ----------------------- end test program -------------------- >Fix: Fix and/or workaround unknown (other than to execute from a created thread). >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-threads@FreeBSD.ORG Mon Aug 6 11:08:40 2007 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 115D316A50F for ; Mon, 6 Aug 2007 11:08:40 +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 00D1213C4B4 for ; Mon, 6 Aug 2007 11:08:39 +0000 (UTC) (envelope-from owner-bugmaster@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 l76B8dNc030042 for ; Mon, 6 Aug 2007 11:08:39 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l76B8cns030038 for freebsd-threads@FreeBSD.org; Mon, 6 Aug 2007 11:08:38 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 6 Aug 2007 11:08:38 GMT Message-Id: <200708061108.l76B8cns030038@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 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, 06 Aug 2007 11:08:40 -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 -------------------------------------------------------------------------------- o kern/20016 threads pthreads: Cannot set scheduling timer/Cannot set virtu 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 o 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 s kern/64313 threads FreeBSD (OpenBSD) pthread implicit set/unset O_NONBLOC o threa/70975 threads unexpected and unreliable behaviour when using SYSV se o threa/72429 threads threads blocked in stdio (fgets, etc) are not cancella 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 o threa/85160 threads [libthr] [patch] libobjc + libpthread/libthr crash pro o kern/91266 threads [threads] Trying sleep, but thread marked as sleeping 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/113666 threads misc/shared-mime-info doesn't install, can't find thre 28 problems total. Non-critical problems S Tracker Resp. Description -------------------------------------------------------------------------------- s kern/19247 threads uthread_sigaction.c does not do anything wrt SA_NOCLDW s kern/22190 threads A threaded read(2) from a socketpair(2) fd can sometim 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/81534 threads [libc_r] [patch] libc_r close() will fail on any fd ty o threa/110306 threads apache 2.0 segmentation violation when calling gethost o threa/114982 threads threads sends error messages to stdout o threa/115211 threads pthread_atfork misbehaves in initial thread 12 problems total.