Skip to content

Commit 19160f0

Browse files
authored
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 <[email protected]>
1 parent 9ba36e2 commit 19160f0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core/iwasm/common/wasm_memory.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,15 @@ wasm_runtime_memory_init(mem_alloc_type_t mem_alloc_type,
534534
static void
535535
destroy_shared_heaps()
536536
{
537-
WASMSharedHeap *heap = shared_heap_list;
537+
WASMSharedHeap *heap;
538538
WASMSharedHeap *cur;
539539
uint64 map_size;
540540

541+
os_mutex_lock(&shared_heap_list_lock);
542+
heap = shared_heap_list;
543+
shared_heap_list = NULL;
544+
os_mutex_unlock(&shared_heap_list_lock);
545+
541546
while (heap) {
542547
cur = heap;
543548
heap = heap->next;
@@ -551,6 +556,7 @@ destroy_shared_heaps()
551556
wasm_munmap_linear_memory(cur->base_addr, cur->size, map_size);
552557
wasm_runtime_free(cur);
553558
}
559+
os_mutex_destroy(&shared_heap_list_lock);
554560
}
555561
#endif
556562

0 commit comments

Comments
 (0)