diff options
author | Paolo Molaro <lupus@oddwiz.org> | 2006-10-10 19:01:25 +0400 |
---|---|---|
committer | Paolo Molaro <lupus@oddwiz.org> | 2006-10-10 19:01:25 +0400 |
commit | c207433145409d3714cfc5e828dca89a87944a99 (patch) | |
tree | 2e1cf9b2de88dcf98c88334ad48bb69b92d78a0b /libgc/darwin_stop_world.c | |
parent | 9318cf2b6ac386005fc50bbb5c6a7386b835d8a7 (diff) |
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.
svn path=/trunk/mono/; revision=66517
Diffstat (limited to 'libgc/darwin_stop_world.c')
-rw-r--r-- | libgc/darwin_stop_world.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/libgc/darwin_stop_world.c b/libgc/darwin_stop_world.c index 3c2d8cfa655..00a25cf62d2 100644 --- a/libgc/darwin_stop_world.c +++ b/libgc/darwin_stop_world.c @@ -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) { |