From 9b2609b468c2823fd037ed92bcc03bf7b429e841 Mon Sep 17 00:00:00 2001 From: TianlongLiang Date: Mon, 26 Jan 2026 14:45:35 +0800 Subject: [PATCH 1/4] fix a bug in zephyr platform file api --- core/shared/platform/zephyr/zephyr_file.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/shared/platform/zephyr/zephyr_file.c b/core/shared/platform/zephyr/zephyr_file.c index 1f48bc010c..2cb1aa5456 100644 --- a/core/shared/platform/zephyr/zephyr_file.c +++ b/core/shared/platform/zephyr/zephyr_file.c @@ -451,6 +451,7 @@ os_openat(os_file_handle handle, const char *path, __wasi_oflags_t oflags, } if (!build_absolute_path(abs_path, sizeof(abs_path), path)) { + BH_FREE(*out); return __WASI_ENOMEM; } From bff386f00fb9a1a1c86525f0fe80c0d5c57db7d2 Mon Sep 17 00:00:00 2001 From: TianlongLiang Date: Mon, 26 Jan 2026 14:48:53 +0800 Subject: [PATCH 2/4] fix a bug in bh queue --- core/shared/utils/bh_queue.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/shared/utils/bh_queue.c b/core/shared/utils/bh_queue.c index ddbb6fffe2..62e5e77c19 100644 --- a/core/shared/utils/bh_queue.c +++ b/core/shared/utils/bh_queue.c @@ -96,14 +96,15 @@ bh_queue_destroy(bh_queue *queue) bool bh_post_msg2(bh_queue *queue, bh_queue_node *msg) { + bh_queue_mutex_lock(&queue->queue_lock); + if (queue->cnt >= queue->max) { queue->drops++; bh_free_msg(msg); + bh_queue_mutex_unlock(&queue->queue_lock); return false; } - bh_queue_mutex_lock(&queue->queue_lock); - if (queue->cnt == 0) { bh_assert(queue->head == NULL); bh_assert(queue->tail == NULL); From b36e27cae414248e1ecad813f916a606267c9b63 Mon Sep 17 00:00:00 2001 From: TianlongLiang Date: Mon, 26 Jan 2026 15:07:47 +0800 Subject: [PATCH 3/4] fix a bug in bh queue --- core/shared/utils/bh_queue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/shared/utils/bh_queue.c b/core/shared/utils/bh_queue.c index 62e5e77c19..4fc756fbe4 100644 --- a/core/shared/utils/bh_queue.c +++ b/core/shared/utils/bh_queue.c @@ -132,7 +132,9 @@ bh_post_msg(bh_queue *queue, unsigned short tag, void *body, unsigned int len) { bh_queue_node *msg = bh_new_msg(tag, body, len, NULL); if (msg == NULL) { + bh_queue_mutex_lock(&queue->queue_lock); queue->drops++; + bh_queue_mutex_unlock(&queue->queue_lock); if (len != 0 && body) BH_FREE(body); return false; From 6dd097a954ca39d9966b521410cfb45f96a97330 Mon Sep 17 00:00:00 2001 From: TianlongLiang Date: Mon, 26 Jan 2026 16:19:16 +0800 Subject: [PATCH 4/4] fix a bug in shared heap malloc when it's memory64 --- core/iwasm/common/wasm_memory.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core/iwasm/common/wasm_memory.c b/core/iwasm/common/wasm_memory.c index 02ab1b764d..21152b37f9 100644 --- a/core/iwasm/common/wasm_memory.c +++ b/core/iwasm/common/wasm_memory.c @@ -796,10 +796,9 @@ wasm_runtime_shared_heap_malloc(WASMModuleInstanceCommon *module_inst, *p_native_addr = native_addr; } - return memory->is_memory64 - ? shared_heap->start_off_mem64 - : shared_heap->start_off_mem32 - + ((uint8 *)native_addr - shared_heap->base_addr); + return (memory->is_memory64 ? shared_heap->start_off_mem64 + : shared_heap->start_off_mem32) + + (uintptr_t)((uint8 *)native_addr - shared_heap->base_addr); } void