فهرست منبع

Fix issues of destroy_shared_heaps (#3847)

Set shared_heap_list to NULL with lock, and destroy shared_heap_list_lock.

Signed-off-by: wenlingyun1 <wenlingyun1@xiaomi.com>
WenLY1 1 سال پیش
والد
کامیت
19160f0e1d
1فایلهای تغییر یافته به همراه7 افزوده شده و 1 حذف شده
  1. 7 1
      core/iwasm/common/wasm_memory.c

+ 7 - 1
core/iwasm/common/wasm_memory.c

@@ -534,10 +534,15 @@ wasm_runtime_memory_init(mem_alloc_type_t mem_alloc_type,
 static void
 destroy_shared_heaps()
 {
-    WASMSharedHeap *heap = shared_heap_list;
+    WASMSharedHeap *heap;
     WASMSharedHeap *cur;
     uint64 map_size;
 
+    os_mutex_lock(&shared_heap_list_lock);
+    heap = shared_heap_list;
+    shared_heap_list = NULL;
+    os_mutex_unlock(&shared_heap_list_lock);
+
     while (heap) {
         cur = heap;
         heap = heap->next;
@@ -551,6 +556,7 @@ destroy_shared_heaps()
         wasm_munmap_linear_memory(cur->base_addr, cur->size, map_size);
         wasm_runtime_free(cur);
     }
+    os_mutex_destroy(&shared_heap_list_lock);
 }
 #endif