Date: Fri, 29 Aug 2008 17:10:43 +0300 From: Kostik Belousov <kostikbel@gmail.com> To: Andriy Gapon <avg@icyb.net.ua> Cc: davidxu@freebsd.org, freebsd-threads@freebsd.org Subject: Re: mysterious hang in pthread_create Message-ID: <20080829141043.GX2038@deviant.kiev.zoral.com.ua> In-Reply-To: <48B71BA6.5040504@icyb.net.ua> References: <48B70A98.5060501@icyb.net.ua> <48B7101E.7060203@icyb.net.ua> <48B71BA6.5040504@icyb.net.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Fri, Aug 29, 2008 at 12:41:58AM +0300, Andriy Gapon wrote:
> on 28/08/2008 23:52 Andriy Gapon said the following:
> >So can all this be a result of an exception thrown before threads are
> >initialized?
>
> This seems to be it.
> I can reproduce the issue with the following small C++ program:
>
> /*********************************************/
> #include <pthread.h>
>
>
> static void * thrfunc(void * arg)
> {
> return NULL;
> }
>
> int main(void)
> {
> pthread_t thr;
>
> try {
> throw int(1);
> }
> catch (...) {}
>
> pthread_create(&thr, NULL, thrfunc, NULL);
>
> return 0;
> }
> /*********************************************/
>
>
> $ uname -a
> ... FreeBSD 7.0-STABLE #9: Sun Jul 6 17:13:22 EEST 2008 ... i386
>
> --
> Andriy Gapon
I am wondering why did you not fixed it youself with all this information.
Anyway, patch below seems to work for me. David may have an opinion on
the change.
diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c
index f96bba9..785d610 100644
--- a/lib/libthr/thread/thr_init.c
+++ b/lib/libthr/thread/thr_init.c
@@ -355,6 +355,9 @@ _libpthread_init(struct pthread *curthread)
if (_thread_event_mask & TD_CREATE)
_thr_report_creation(curthread, curthread);
}
+
+ if (_thr_isthreaded() == 0)
+ _thr_setthreaded(1);
}
/*
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (FreeBSD)
iEYEARECAAYFAki4A2IACgkQC3+MBN1Mb4ghwACg48Cq54kIYCRiNPZv4+9fQKsJ
sycAniWJY6CZ2kw79wGzxCWaJfPCvq9L
=Rdug
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080829141043.GX2038>
