Tue Oct 10 16:58:37 CEST 2006 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Tue, 10 Oct 2006 15:01:25 +0000 (15:01 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Tue, 10 Oct 2006 15:01:25 +0000 (15:01 -0000)
* darwin_stop_world.c: patch from Allan Hsu <allan@counterpop.net>
to avoid using memory just after freeing it.

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

libgc/ChangeLog
libgc/darwin_stop_world.c

index 9310414fe84dfe961753abff01c4f5215248fd76..06ed8152122af4657254e207508d192253cb3a18 100644 (file)
@@ -1,3 +1,9 @@
+
+Tue Oct 10 16:58:37 CEST 2006 Paolo Molaro <lupus@ximian.com>
+
+       * darwin_stop_world.c: patch from Allan Hsu <allan@counterpop.net>
+       to avoid using memory just after freeing it.
+
 2006-08-31  Zoltan Varga  <vargaz@freemail.hu>
 
        * libgc.vcproj: Define GC_INSIDE_DLL on VC build too.
index 3c2d8cfa655d44bb725e80733aa5cd662abea67b..00a25cf62d24bda6185917df2c755d27fac807cd 100644 (file)
@@ -411,24 +411,31 @@ void GC_stop_world()
       prev_list = NULL;
       prevcount = 0;
       do {
-       int result;
+       int result;               
        kern_result = task_threads(my_task, &act_list, &listcount);
-       result = GC_suspend_thread_list(act_list, listcount,
-                                       prev_list, prevcount);
-       changes = result;
-       prev_list = act_list;
-       prevcount = listcount;
        
-       if(kern_result == KERN_SUCCESS) {
-               int i;
+       if(kern_result == KERN_SUCCESS) {       
+               result = GC_suspend_thread_list(act_list, listcount,
+                                                                               prev_list, prevcount);
+               changes = result;
                
-               for(i = 0; i < listcount; i++)
-                       mach_port_deallocate(my_task, act_list[i]);
+               if(prev_list != NULL) {
+                       for(i = 0; i < prevcount; i++)
+                               mach_port_deallocate(my_task, prev_list[i]);
+                       
+                       vm_deallocate(my_task, (vm_address_t)prev_list, sizeof(thread_t) * prevcount);
+               }
                
-               vm_deallocate(my_task, (vm_address_t)act_list, sizeof(thread_t) * listcount);
-       }
+               prev_list = act_list;
+               prevcount = listcount;
+       }               
       } while (changes);
-      
+     
+         for(i = 0; i < listcount; i++)
+                 mach_port_deallocate(my_task, act_list[i]);
+         
+         vm_deallocate(my_task, (vm_address_t)act_list, sizeof(thread_t) * listcount);
+         
  
 #   ifdef MPROTECT_VDB
       if(GC_incremental) {