Skip to content

Commit 464bb03

Browse files
author
Hritik Gupta
committed
fix: added acquiring lock while map copy
1 parent 4675c70 commit 464bb03

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/iwasm/common/wasm_shared_memory.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ create_copy_of_wait_map(void *key, void *value, void *map_copy)
105105
void
106106
notify_stale_threads_on_exception(WASMModuleInstanceCommon *module_inst)
107107
{
108-
109108
static HashMap *wait_map_without_lock;
110109
wait_map_without_lock = bh_hash_map_create(
111110
32, false, (HashFunc)wait_address_hash,
@@ -115,8 +114,10 @@ notify_stale_threads_on_exception(WASMModuleInstanceCommon *module_inst)
115114
* this allows invoking methods in the callback
116115
* which require acquiring lock on the original map
117116
*/
117+
os_mutex_lock(&shared_memory_list_lock);
118118
bh_hash_map_traverse(wait_map, create_copy_of_wait_map,
119119
wait_map_without_lock);
120+
os_mutex_unlock(&shared_memory_list_lock);
120121

121122
// terminate stale threads
122123
bh_hash_map_traverse(wait_map_without_lock, notify_stale_threads,

0 commit comments

Comments
 (0)