From owner-freebsd-threads@FreeBSD.ORG Mon Aug 27 11:08:39 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 3585516A558 for ; Mon, 27 Aug 2007 11:08:39 +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 21A1413C46B for ; Mon, 27 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 l7RB8ccW020696 for ; Mon, 27 Aug 2007 11:08:38 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l7RB8bVQ020692 for freebsd-threads@FreeBSD.org; Mon, 27 Aug 2007 11:08:37 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 27 Aug 2007 11:08:37 GMT Message-Id: <200708271108.l7RB8bVQ020692@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, 27 Aug 2007 11:08:39 -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. From owner-freebsd-threads@FreeBSD.ORG Mon Aug 27 13:40:06 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 6455916A419 for ; Mon, 27 Aug 2007 13:40:06 +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 4BDD813C46B for ; Mon, 27 Aug 2007 13:40:06 +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 l7RDe6dw034238 for ; Mon, 27 Aug 2007 13:40:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l7RDe6jl034237; Mon, 27 Aug 2007 13:40:06 GMT (envelope-from gnats) Date: Mon, 27 Aug 2007 13:40:06 GMT Message-Id: <200708271340.l7RDe6jl034237@freefall.freebsd.org> To: freebsd-threads@FreeBSD.org From: sysmaint@contek.com (Douglas Wells) Cc: Subject: Re: 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: Mon, 27 Aug 2007 13:40:06 -0000 The following reply was made to PR threads/115211; it has been noted by GNATS. From: sysmaint@contek.com (Douglas Wells) To: Craig Rodrigues Cc: bug-followup@FreeBSD.org, sysmaint@contek.com Subject: Re: threads/115211: pthread_atfork misbehaves in initial thread Date: Mon, 27 Aug 2007 08:46:52 -0400 (EDT) > Hi, > > On FreeBSD-CURRENT, if I do: > > gcc pthread_atforkbug.c -lkse && ./a.out > > This is the output: > > parent pid (48871) > Child exiting: (48872) > child (48872) returned > > If I do: > > gcc pthread_atforkbug.c -lkse && ./a.out > > parent pid (48877) > af_prepare: pid (48877) > af_parent: pid (48877) > af_child: pid (48878) > Child exiting: (48878) > child (48878) returned > > > On FreeBSD 6.2, -pthread is mapped to -lkse, while on CURRENT, it is mapped > to -lthr. Can you try your test again with -lthr on FreeBSD 6.2? > This looks like a libkse bug. > > -- > Craig Rodrigues > rodrigc@crodrigues.org Yes, I can verify that using: -pthread => erroneous behavior -lthr => expected behavior on my installation of 6.2. - dmw From owner-freebsd-threads@FreeBSD.ORG Mon Aug 27 14:07:03 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 55CE216A419 for ; Mon, 27 Aug 2007 14:07:03 +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 1714913C4A6 for ; Mon, 27 Aug 2007 14:07:02 +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.1/8.14.1/NETPLEX) with ESMTP id l7RDoWAd015680; Mon, 27 Aug 2007 09:50:32 -0400 (EDT) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-3.0 (mail.netplex.net [204.213.176.10]); Mon, 27 Aug 2007 09:50:32 -0400 (EDT) Date: Mon, 27 Aug 2007 09:50:32 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Douglas Wells In-Reply-To: <200708271340.l7RDe6jl034237@freefall.freebsd.org> Message-ID: References: <200708271340.l7RDe6jl034237@freefall.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-threads@freebsd.org Subject: Re: threads/115211: pthread_atfork misbehaves in initial thread 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: Mon, 27 Aug 2007 14:07:03 -0000 On Mon, 27 Aug 2007, Douglas Wells wrote: > > Yes, I can verify that using: > -pthread => erroneous behavior > -lthr => expected behavior > on my installation of 6.2. The problem is that the program isn't threaded yet. I'm not sure if this is really a problem since pthread_atfork() is used to protect and initialize data when a multi-threaded program forks. If the program isn't threaded, is there really a need to do this? That said, it should work regardless. -- DE From owner-freebsd-threads@FreeBSD.ORG Mon Aug 27 17:01:00 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 E9F0E16A418; Mon, 27 Aug 2007 17:01: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 5B74513C4B6; Mon, 27 Aug 2007 17:01:00 +0000 (UTC) (envelope-from sysmaint@contek.com) Received: from mr08.lnh.mail.rcn.net ([207.172.157.28]) by smtp02.lnh.mail.rcn.net with ESMTP; 27 Aug 2007 12:32:18 -0400 Received: from smtp01.lnh.mail.rcn.net (smtp01.lnh.mail.rcn.net [207.172.4.11]) by mr08.lnh.mail.rcn.net (MOS 3.8.3-GA) with ESMTP id JAR95611; Mon, 27 Aug 2007 12:32:18 -0400 (EDT) Received: from 207-172-216-114.s876.apx1.sbo.ma.dialup.rcn.com (HELO mail.contek.com) ([207.172.216.114]) by smtp01.lnh.mail.rcn.net with ESMTP; 27 Aug 2007 12:32:17 -0400 Received: by mail.contek.com (Postfix, from userid 10112) id 31764399A2; Mon, 27 Aug 2007 12:32:16 -0400 (EDT) In-Reply-To: To: Daniel Eischen Date: Mon, 27 Aug 2007 12:32:15 -0400 (EDT) X-Mailer: ELM [version 2.4ME+ PL123f (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="US-ASCII" Message-Id: <20070827163216.31764399A2@mail.contek.com> From: sysmaint@contek.com (Douglas Wells) Cc: Douglas Wells , freebsd-threads@freebsd.org Subject: Re: threads/115211: pthread_atfork misbehaves in initial thread 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, 27 Aug 2007 17:01:01 -0000 > On Mon, 27 Aug 2007, Douglas Wells wrote: > > > Yes, I can verify that using: > > -pthread => erroneous behavior > > -lthr => expected behavior > > on my installation of 6.2. > > The problem is that the program isn't threaded yet. I'm not sure if > this is really a problem since pthread_atfork() is used to protect > and initialize data when a multi-threaded program forks. If the > program isn't threaded, is there really a need to do this? No, I did not actually encounter this problem in a real program. I came upon it based upon a discussion elsewhere. When I encountered the problem on FreeBSD, I reported it with low priority. > That said, it should work regardless. Exactly. > DE - dmw From owner-freebsd-threads@FreeBSD.ORG Thu Aug 30 21:20:39 2007 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7242416A41B for ; Thu, 30 Aug 2007 21:20:39 +0000 (UTC) (envelope-from jin@george.lbl.gov) Received: from smtp117.sbc.mail.sp1.yahoo.com (smtp117.sbc.mail.sp1.yahoo.com [69.147.64.90]) by mx1.freebsd.org (Postfix) with SMTP id 456E013C48A for ; Thu, 30 Aug 2007 21:20:39 +0000 (UTC) (envelope-from jin@george.lbl.gov) Received: (qmail 29050 invoked from network); 30 Aug 2007 21:20:38 -0000 Received: from unknown (HELO ?192.168.1.238?) (jinmtb@sbcglobal.net@67.111.218.125 with plain) by smtp117.sbc.mail.sp1.yahoo.com with SMTP; 30 Aug 2007 21:20:38 -0000 X-YMail-OSG: xyPvLToVM1lFDdgigf0Hrh3CJYzCs.AOLm3t9eDBNuy9Rm.IC5DNBndtpcfl0Ek7mbiUJDpwVg-- Message-ID: <46D734A1.2090700@george.lbl.gov> Date: Thu, 30 Aug 2007 14:20:33 -0700 From: Jin Guojun User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.13) Gecko/20061027 X-Accept-Language: zh, zh-CN, en MIME-Version: 1.0 To: threads@freebsd.org References: <46B245D5.1050606@george.lbl.gov> <20070803090530.GH2738@deviant.kiev.zoral.com.ua> In-Reply-To: <20070803090530.GH2738@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: hackers@freebsd.org Subject: How TLS is used in Kernel thread 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, 30 Aug 2007 21:20:39 -0000 By looking through _pthread_create() code and find it uses a magic cookie -- TLS -- created by rtld_allocate_tls(), and passed into kernel by sysarch() via _tcb_set() / _kcb_set(). The information seems to be set by rtld (ld-elf.so.1) in digest_phdr() under tag PT_TLS. But it is very magic for where the TLS object is created and how it is passed to digest_phdr(). The whole object passed into kernel (as sd.gsbase) looks like this: TCB: ______________________________ | TLS | TCB | |______________|_______________| Can someone give some basic exaplain on following questions? 1) What TLS stand for? 2) Where TLS object is created? (below is the tls assigned, but I couls not find where ph is from) case PT_TLS: obj->tlsindex = 1; obj->tlssize = ph->p_memsz; obj->tlsalign = ph->p_align; obj->tlsinitsize = ph->p_filesz; obj->tlsinit = (void*) ph->p_vaddr; 3) Where in kernel the TLS is used for thread operation? Thanks in advance, -Jin