missing error-checking in libpthread?

Daniel Eischen eischen at vigrid.com
Thu Apr 8 08:55:41 PDT 2004


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



More information about the freebsd-threads mailing list