-lthread_xu and core dump on __error()

YONETANI Tomokazu qhwt+dfly at les.ath.cx
Thu Apr 28 02:07:41 PDT 2005


Hi.
After the TLS change, linking against -lthread_xu resulted in segmentation
fault in somewhere inside __error(). After looking closely what's been
changed, I found that the _get_curthread() (which had been defined as
an inline function in pthread_md.h and was replaced by tls_get_curthread())
had a conditional against _thr_initial to have a non-NULL value around
the call to TCB_GET32/TCP_GET64, but it's not in tls_get_curthread().
So I tried the following patch and it seems to work(not heavily tested yet):

%%%
Index: lib/libthread_xu/sys/thr_error.c
===================================================================
RCS file: /dragonfly/cvs/src/lib/libthread_xu/sys/thr_error.c,v
retrieving revision 1.2
diff -u -r1.2 thr_error.c
--- lib/libthread_xu/sys/thr_error.c	29 Mar 2005 19:26:20 -0000	1.2
+++ lib/libthread_xu/sys/thr_error.c	28 Apr 2005 08:53:25 -0000
@@ -45,8 +45,10 @@
 int *
 __error(void)
 {
-	struct pthread *curthread = tls_get_curthread();
+	struct pthread *curthread = NULL;
 
+	if (_thr_initial != NULL)
+	    curthread = tls_get_curthread();
 	if (curthread != _thr_initial)
 		return (&curthread->error);
 	else
%%%

But I'm not sure this is the right place to add back the check against
_thr_initial, and why the same check is not needed elsewhere
(and I've seen nobody else reported this before).

Regards.





More information about the Bugs mailing list