From owner-freebsd-threads@FreeBSD.ORG Mon Apr 2 11:08:25 2007 Return-Path: X-Original-To: freebsd-threads@FreeBSD.org Delivered-To: freebsd-threads@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B09E616A4EA for ; Mon, 2 Apr 2007 11:08:25 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id 9F8B513C4D1 for ; Mon, 2 Apr 2007 11:08:25 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (linimon@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id l32B8PUr052301 for ; Mon, 2 Apr 2007 11:08:25 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from linimon@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id l32B8OPn052297 for freebsd-threads@FreeBSD.org; Mon, 2 Apr 2007 11:08:24 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 2 Apr 2007 11:08:24 GMT Message-Id: <200704021108.l32B8OPn052297@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: linimon 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, 02 Apr 2007 11:08:25 -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 threa/90278 threads libthr, ULE and -current produces >100% WCPU with apac 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 f threa/98256 threads gnome-system-monitor core dumps from pthread_testcance 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 using gdb with multi thread application with lib libpt 29 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 10 problems total. From owner-freebsd-threads@FreeBSD.ORG Wed Apr 4 21:36:04 2007 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B6BC416A402 for ; Wed, 4 Apr 2007 21:36:04 +0000 (UTC) (envelope-from ed.maste@gmail.com) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.171]) by mx1.freebsd.org (Postfix) with ESMTP id 6234F13C45E for ; Wed, 4 Apr 2007 21:36:02 +0000 (UTC) (envelope-from ed.maste@gmail.com) Received: by ug-out-1314.google.com with SMTP id 71so843757ugh for ; Wed, 04 Apr 2007 14:36:02 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=CmHiibm6vlMMz8wDQahsrqXaHFJ3DShCZXUfTFzGh2MqPIxYkXLRm8ROwWK7NRiw68bshvQ08Z2KRwO17aVVqeByhmB76PUArVJjwZYomLeeux+KdCu3A6UXVq4hY1xMo4PvCx4JkBc0/qlCbEbJkE8GY5yEDPYvaTZQq80v4yY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=fm44patzP14e8AZIKnresPRF3x9YhFTeEEb+Rag+T1CytCCDpfUOMWaPPLdsESOQQB2zmlhETYXvCQfGy0SWg8mpuVbW2Ik7flSu5+2YjIP+au7MkYpb7LG9b0NUtpFNJKwNa7CLvzx7NfuPCqQXPPdR5nU6dqXUL6ozDpCBceM= Received: by 10.78.123.4 with SMTP id v4mr208812huc.1175721302556; Wed, 04 Apr 2007 14:15:02 -0700 (PDT) Received: by 10.78.188.7 with HTTP; Wed, 4 Apr 2007 14:14:57 -0700 (PDT) Message-ID: <88607eb20704041414s6bda8765u6782a0460372407f@mail.gmail.com> Date: Wed, 4 Apr 2007 17:14:57 -0400 From: "Ed Maste" To: freebsd-threads@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: [PATCH] libthr - pthread_set_name_np crash 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, 04 Apr 2007 21:36:04 -0000 It seems there is a bug in pthread_set_name_np for the thread != curthread case. That is, pthread_set_name_np called from outside of the thread being named, as in the following example: pthread_create(&pt, 0, t_spin, (void *)1); [...] pthread_set_name_np(pt, "t1"); The bug is a race condition that leads to thread->locklevel being incorrect. Based on the other cases of locking a not-curthread thread, I think the patch below is the fix. Can a libthr expert comment? Thanks, Ed Index: thr_info.c =================================================================== RCS file: /usr/cvs/src/lib/libthr/thread/thr_info.c,v retrieving revision 1.9 diff -u -r1.9 thr_info.c --- thr_info.c 12 Jan 2007 07:26:20 -0000 1.9 +++ thr_info.c 23 Mar 2007 14:56:13 -0000 @@ -52,12 +52,12 @@ ret = errno; } else { if (_thr_ref_add(curthread, thread, 0) == 0) { - THR_LOCK(thread); + THR_THREAD_LOCK(curthread, thread); if (thread->state != PS_DEAD) { if (thr_set_name(thread->tid, name)) ret = errno; } - THR_UNLOCK(thread); + THR_THREAD_UNLOCK(curthread, thread); _thr_ref_delete(curthread, thread); } else { ret = ESRCH; From owner-freebsd-threads@FreeBSD.ORG Thu Apr 5 02:33:03 2007 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 78DAE16A402; Thu, 5 Apr 2007 02:33:02 +0000 (UTC) (envelope-from davidxu@freebsd.org) Message-ID: <46145FF4.9080703@freebsd.org> Date: Thu, 05 Apr 2007 10:33:24 +0800 From: David Xu User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.13) Gecko/20061204 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ed Maste References: <88607eb20704041414s6bda8765u6782a0460372407f@mail.gmail.com> In-Reply-To: <88607eb20704041414s6bda8765u6782a0460372407f@mail.gmail.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-threads@freebsd.org Subject: Re: [PATCH] libthr - pthread_set_name_np crash 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, 05 Apr 2007 02:33:03 -0000 Ed Maste wrote: > It seems there is a bug in pthread_set_name_np for the thread != curthread > case. That is, pthread_set_name_np called from outside of the thread > being named, as in the following example: > > pthread_create(&pt, 0, t_spin, (void *)1); > [...] > pthread_set_name_np(pt, "t1"); > > The bug is a race condition that leads to thread->locklevel being > incorrect. Based on the other cases of locking a not-curthread thread, > I think the patch below is the fix. Can a libthr expert comment? > > Thanks, > Ed > > Index: thr_info.c > =================================================================== > RCS file: /usr/cvs/src/lib/libthr/thread/thr_info.c,v > retrieving revision 1.9 > diff -u -r1.9 thr_info.c > --- thr_info.c 12 Jan 2007 07:26:20 -0000 1.9 > +++ thr_info.c 23 Mar 2007 14:56:13 -0000 > @@ -52,12 +52,12 @@ > ret = errno; > } else { > if (_thr_ref_add(curthread, thread, 0) == 0) { > - THR_LOCK(thread); > + THR_THREAD_LOCK(curthread, thread); > if (thread->state != PS_DEAD) { > if (thr_set_name(thread->tid, name)) > ret = errno; > } > - THR_UNLOCK(thread); > + THR_THREAD_UNLOCK(curthread, thread); > _thr_ref_delete(curthread, thread); > } else { > ret = ESRCH; Yes, this patch is correct, please commit it. Regards, David Xu