From owner-freebsd-threads@FreeBSD.ORG Thu Apr 8 08:55:41 2004 Return-Path: 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 CA4F616A4E3 for ; Thu, 8 Apr 2004 08:55:41 -0700 (PDT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 622AE43D5C for ; Thu, 8 Apr 2004 08:55:41 -0700 (PDT) (envelope-from eischen@vigrid.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.10/8.12.1) with ESMTP id i38FtPtf027481; Thu, 8 Apr 2004 11:55:25 -0400 (EDT) Date: Thu, 8 Apr 2004 11:55:25 -0400 (EDT) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: Dan Nelson In-Reply-To: <20040408150553.GA8182@dan.emsphone.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-threads@freebsd.org Subject: Re: missing error-checking in libpthread? X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Apr 2004 15:55:41 -0000 On Thu, 8 Apr 2004, Dan Nelson wrote: > > I'm seeing the following stack trace in a testsuite for a threaded > program. At the time I generated the coredump, the process was in a > loop calling kse_release({0,1000000}) about 1.5 million times/sec, > every call returning EINVAL. > > There are three calls to kse_release in thr_kern.c and one in > thr_sig.c, none of which check the returnvalue. The call in thr_sig.c > and two of the calls in thr_kern.c even have code after kse_release() > as if they expected the call to return (which it shouldn't under normal > circumstances). One call in thr_kern.c has a /* Never reach */ commect > after the call to kse_release, but again, no checks or calls to abort() > if it does happen. Can you try this patch? Index: thr_kern.c =================================================================== RCS file: /opt/FreeBSD/cvs/src/lib/libpthread/thread/thr_kern.c,v retrieving revision 1.105 diff -u -r1.105 thr_kern.c --- thr_kern.c 19 Dec 2003 13:24:54 -0000 1.105 +++ thr_kern.c 8 Apr 2004 15:47:00 -0000 @@ -347,13 +347,14 @@ _thr_signal_deinit(); } __isthreaded = 0; + curthread->kse->k_kcb->kcb_kmbx.km_curthread = NULL; + curthread->attr.flags |= PTHREAD_SCOPE_SYSTEM; + /* * Restore signal mask early, so any memory problems could * dump core. */ sigprocmask(SIG_SETMASK, &curthread->sigmask, NULL); - curthread->kse->k_kcb->kcb_kmbx.km_curthread = NULL; - curthread->attr.flags |= PTHREAD_SCOPE_SYSTEM; _thr_active_threads = 1; #endif } -- Dan Eischen