[Mono-bugs] [Bug 82795][Cri] New - Thread abort when finishing the program

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Mon Sep 10 19:31:57 EDT 2007

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 lenzi.sergio at gmail.com.


--- shadow/82795	2007-09-10 19:31:57.000000000 -0400
+++ shadow/82795.tmp.10020	2007-09-10 19:31:57.000000000 -0400
@@ -0,0 +1,71 @@
+Bug#: 82795
+Product: Mono: Runtime
+Version: 1.2
+OS: other
+OS Details: FreeBSD 6.2 Stable i386 32 bits dual processor 
+Status: NEW   
+Priority: Critical
+Component: io-layer
+AssignedTo: dick at ximian.com                            
+ReportedBy: lenzi.sergio at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: Thread abort when finishing the program
+Description of Problem: when finishing a program(mono) that uses
+gtk-sharp20 and gnome-sharp, the mono sometimes displays a message on
+stdout telling about thread not finish correctly.
+Steps to reproduce the problem:
+1. execute muine, monodevelop... or any program that uses gnome-sharp
+2. in a system with 2 process (dual core) cpus
+Actual Results:
+displays: thread XXXXX  and error message...
+Expected Results:
+should display nothing at normal program exit
+How often does this happen? 
+6 times in 10...
+Additional Information:
+A trace in the error message (I have not the error message any more because
+I corrected the bug...) shows that it came from the thread library in the
+FreeBSD (libpthread)..  The problem arrives in the calling of the function
+pthread_key_delete as it is called before the thread ends, and so the
+handler is thus invalid after the final finish of the thread code. 
+When using 2 cpus, the problem occurs more.. 
+A patch in my mono-code fixed the problem, as I think it is not necessary
+to delete the key at the end of the thread, as it will be vanish anyway by
+the time the thread ends.
+If you all have a better idea, please let me know....
+--- mono/io-layer/threads.c.orig        Mon Sep 10 10:20:27 2007
++++ mono/io-layer/threads.c     Mon Sep 10 10:20:52 2007
+@@ -852,7 +852,7 @@
+  */
+ gboolean TlsFree(guint32 idx)
+ {
+-       int thr_ret;
++       int thr_ret=0;
+ #ifdef TLS_DEBUG
+        g_message ("%s: freeing key %d", __func__, idx);
+@@ -866,7 +866,7 @@
+        }
+        TLS_used[idx]=FALSE;
+-       thr_ret = pthread_key_delete(TLS_keys[idx]);
++//     thr_ret = pthread_key_delete(TLS_keys[idx]);
+        g_assert (thr_ret == 0);
+        MONO_SPIN_UNLOCK (TLS_spinlock);

More information about the mono-bugs mailing list