2005-06-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Mon, 6 Jun 2005 03:21:45 +0000 (03:21 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Mon, 6 Jun 2005 03:21:45 +0000 (03:21 -0000)
* threads.c: avoid segfault when an unstarted thread is aborted.

svn path=/trunk/mono/; revision=45463

mono/metadata/ChangeLog
mono/metadata/threads.c

index c1f5f59f4c8c4bbc7c319360b602bd692b6de082..752f6450fee9a981b47625d0d1584da7350b5245 100644 (file)
@@ -1,3 +1,7 @@
+2005-06-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * threads.c: avoid segfault when an unstarted thread is aborted.
+
 2005-06-05  Kornél Pál <kornelpal@hotmail.com>
 
        * icall.c: Added ves_icall_Mono_Runtime_GetDisplayName:
index 07f5e1c9de78f3afa19aba972157c870cb63c857..62ce8fc330ffeb2a37f4e8b8ae76afe966b0ada7 100644 (file)
@@ -479,7 +479,8 @@ HANDLE ves_icall_System_Threading_Thread_Thread_internal(MonoThread *this,
 
        mono_monitor_enter (this->synch_lock);
 
-       if ((this->state & ThreadState_Unstarted) == 0) {
+       if ((this->state & ThreadState_Unstarted) == 0 ||
+           (this->state & ThreadState_Aborted) != 0) {
                mono_monitor_exit (this->synch_lock);
                mono_raise_exception (mono_get_exception_thread_state ("Thread has already been started."));
                return NULL;
@@ -1434,6 +1435,12 @@ ves_icall_System_Threading_Thread_Abort (MonoThread *thread, MonoObject *state)
                return;
        }
 
+       if ((thread->state & ThreadState_Unstarted) != 0) {
+               thread->state |= ThreadState_Aborted;
+               mono_monitor_exit (thread->synch_lock);
+               return;
+       }
+
        thread->state |= ThreadState_AbortRequested;
        thread->abort_state = state;
        thread->abort_exc = NULL;