Skip to content

Commit

Permalink
Fix issues of destroy_shared_heaps (#3847)
Browse files Browse the repository at this point in the history
Set shared_heap_list to NULL with lock, and destroy shared_heap_list_lock.

Signed-off-by: wenlingyun1 <wenlingyun1@xiaomi.com>
  • Loading branch information
WenLY1 authored Oct 10, 2024
1 parent 9ba36e2 commit 19160f0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/iwasm/common/wasm_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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

Expand Down

0 comments on commit 19160f0

Please sign in to comment.