Merge pull request #900 from Blewzman/FixAggregateExceptionGetBaseException
[mono.git] / mono / metadata / sgen-gc.c
index 23cca50895138efb1ab1964ff0103da85f4ae5e8..880ce493e13937c6f9219c83c3799b0e57f28ad9 100644 (file)
@@ -4113,7 +4113,10 @@ sgen_thread_register (SgenThreadInfo* info, void *addr)
 
        binary_protocol_thread_register ((gpointer)mono_thread_info_get_tid (info));
 
+       /* On win32, stack_start_limit should be 0, since the stack can grow dynamically */
+#ifndef HOST_WIN32
        mono_thread_info_get_stack_bounds (&staddr, &stsize);
+#endif
        if (staddr) {
                info->stack_start_limit = staddr;
                info->stack_end = staddr + stsize;
@@ -4151,8 +4154,13 @@ sgen_thread_detach (SgenThreadInfo *p)
 static void
 sgen_thread_unregister (SgenThreadInfo *p)
 {
-       binary_protocol_thread_unregister ((gpointer)mono_thread_info_get_tid (p));
-       SGEN_LOG (3, "unregister thread %p (%p)", p, (gpointer)mono_thread_info_get_tid (p));
+       MonoNativeThreadId tid;
+
+       tid = mono_thread_info_get_tid (p);
+       binary_protocol_thread_unregister ((gpointer)tid);
+       SGEN_LOG (3, "unregister thread %p (%p)", p, (gpointer)tid);
+
+       mono_threads_add_joinable_thread ((gpointer)tid);
 
        if (gc_callbacks.thread_detach_func) {
                gc_callbacks.thread_detach_func (p->runtime_data);
@@ -4222,7 +4230,7 @@ mono_gc_pthread_detach (pthread_t thread)
 void
 mono_gc_pthread_exit (void *retval) 
 {
-       mono_thread_info_dettach ();
+       mono_thread_info_detach ();
        pthread_exit (retval);
 }
 
@@ -4846,6 +4854,7 @@ mono_gc_base_init (void)
        cb.thread_attach = sgen_thread_attach;
        cb.mono_method_is_critical = (gpointer)is_critical_method;
 #ifndef HOST_WIN32
+       cb.thread_exit = mono_gc_pthread_exit;
        cb.mono_gc_pthread_create = (gpointer)mono_gc_pthread_create;
 #endif