[Mono-bugs] [Bug 65379][Nor] New - race condition in thread exit code

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 6 Sep 2004 08:14:24 -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 vargaz@freemail.hu.

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

--- shadow/65379	2004-09-06 08:14:24.000000000 -0400
+++ shadow/65379.tmp.5593	2004-09-06 08:14:24.000000000 -0400
@@ -0,0 +1,30 @@
+Bug#: 65379
+Product: Mono: Runtime
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: vargaz@freemail.hu               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: race condition in thread exit code
+
+There seems to be a race condition in the thread exit code, which can be
+seen by running tests/thread5.exe in a loop. After a while, it hangs.
+I debugged this, and the following seems to happen:
+
+_wapi_timed_thread_exit () calls pthread_exit (), which calls the
+mono_thread_detach function registered by start_wrapper ().
+mono_thread_detach () indirectly calls WaitForSingleObjectExt () which
+calls GetCurrentThread (), which doesn't find the thread in thread_hash
+since it is already removed, so it calls thread_attach (), which allocates
+a new handle and puts it into thread_hash. Later, when mono_thread_manage
+tries to wait for this thread to die, it waits on the new handle, which of
+course is never signalled, so the runtime hangs.