[Mono-bugs] [Bug 68134][Maj] Changed - Mono runtime hangs on FreeBSD 4.8

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 13 Oct 2004 16:33:53 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by cmcclellen@weather.com.

http://bugzilla.ximian.com/show_bug.cgi?id=68134

--- shadow/68134	2004-10-13 14:18:43.000000000 -0400
+++ shadow/68134.tmp.14461	2004-10-13 16:33:53.000000000 -0400
@@ -70,6 +70,45 @@
 ------- Additional Comments From cmcclellen@weather.com  2004-10-13 14:18 -------
 
 We notice that when mcs hangs, it is also stuck in 
 _cond_wait_backout.  That seems to be some kind of wait during a 
 thread exit.
 
+
+------- Additional Comments From cmcclellen@weather.com  2004-10-13 16:33 -------
+It looks like there may be a decent bug in thread handling.
+
+A timed thread is started... which executes this line of code
+(inside timed_thread_start_routine):
+
+_wapi_timed_thread_exit(thread->start_routine(thread->arg));
+
+As you can see, when the timed thread returns from its start routine,
+it will call thread exit.
+
+HOWEVER, before it returns, "thread_exit" is called, which in turn 
+calls thread_close_private... which does the following:
+
+        if(thread_handle->thread!=NULL) {
+                _wapi_timed_thread_destroy (thread_handle->thread);
+        }
+
+So, it kills the exit condition, and gfree's the thread.
+
+When the start routine finally returns, thread exit starts accessing
+freed memory.  In some circumstances, (with -DDEBUG) I can get it
+to core dump in the timed_thread_exit routine.
+
+It seems the GC thread causes this...  Also, it seems that the line 
+of code:
+   if((specific = pthread_getspecific(timed_thread_key)) == NULL) {
+                /* Handle cases which won't happen with correct 
+usage.
+                 */
+                pthread_exit(NULL);
+        }
+
+
+If I'm right about all this, it is a pretty decent bug that will 
+cause lots of weird problems esp with async io.
+
+in timed_thread_exit doesn't prevent this stuff from happening.