From c207433145409d3714cfc5e828dca89a87944a99 Mon Sep 17 00:00:00 2001 From: Paolo Molaro Date: Tue, 10 Oct 2006 15:01:25 +0000 Subject: [PATCH] Tue Oct 10 16:58:37 CEST 2006 Paolo Molaro * darwin_stop_world.c: patch from Allan Hsu to avoid using memory just after freeing it. svn path=/trunk/mono/; revision=66517 --- libgc/ChangeLog | 6 ++++++ libgc/darwin_stop_world.c | 33 ++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/libgc/ChangeLog b/libgc/ChangeLog index 9310414fe84..06ed8152122 100644 --- a/libgc/ChangeLog +++ b/libgc/ChangeLog @@ -1,3 +1,9 @@ + +Tue Oct 10 16:58:37 CEST 2006 Paolo Molaro + + * darwin_stop_world.c: patch from Allan Hsu + to avoid using memory just after freeing it. + 2006-08-31 Zoltan Varga * libgc.vcproj: Define GC_INSIDE_DLL on VC build too. 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) { -- 2.25.1