Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/iwasm/aot/aot_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ aot_module_malloc(AOTModuleInstance *module_inst, uint32 size,
aot_set_exception(module_inst, "app heap corrupted");
}
else {
aot_set_exception(module_inst, "out of memory");
LOG_ERROR("alloc %d bytes memory failed", size);
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/interpreter/wasm_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,7 @@ wasm_module_malloc(WASMModuleInstance *module_inst, uint32 size,
wasm_set_exception(module_inst, "app heap corrupted");
}
else {
wasm_set_exception(module_inst, "out of memory");
LOG_ERROR("alloc %d bytes memory failed", size);
}
return 0;
}
Expand Down
9 changes: 7 additions & 2 deletions core/shared/utils/bh_hashmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,13 @@ bh_hash_map_find(HashMap *map, void *key)
HashMapElem *elem;
void *value;

if (!map || !key) {
LOG_ERROR("HashMap find elem failed: map or key is NULL.\n");
if (!map) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that we should modify acquire_wait_info in wasm_shared_memory.c but not here, e.g. change to:

static AtomicWaitInfo *
acquire_wait_info(void *address, bool create)
{
    AtomicWaitInfo *wait_info = NULL;
    bh_list_status ret;

    if (address)    => add check here
        wait_info = (AtomicWaitInfo *)bh_hash_map_find(wait_map, address);

    if (!create)
        return wait_info;

@xujuntwt95329, what's you opinion? Qi found that "In acquire_wait_info the key of hasn_map_find can be NULL thus there are many senseless error logs".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree with @wenyongh, the caller should avoid passing NULL pointer to bh_hash_map_find

LOG_ERROR("HashMap find elem failed: map is NULL.\n");
return NULL;
}

if (!key) {
LOG_VERBOSE("HashMap find elem failed: key is NULL.\n");
return NULL;
}

Expand Down