Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Apr 2004 11:55:25 -0400 (EDT)
From:      Daniel Eischen <eischen@vigrid.com>
To:        Dan Nelson <dnelson@allantgroup.com>
Cc:        freebsd-threads@freebsd.org
Subject:   Re: missing error-checking in libpthread?
Message-ID:  <Pine.GSO.4.10.10404081154380.27251-100000@pcnet5.pcnet.com>
In-Reply-To: <20040408150553.GA8182@dan.emsphone.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10404081154380.27251-100000>