Skip to content

Commit 733ac3f

Browse files
Collective fix (#4808)
* fix a bug in zephyr platform file api * fix a bug in bh queue * fix a bug in shared heap malloc when it's memory64
1 parent 33680c7 commit 733ac3f

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

core/iwasm/common/wasm_memory.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -796,10 +796,9 @@ wasm_runtime_shared_heap_malloc(WASMModuleInstanceCommon *module_inst,
796796
*p_native_addr = native_addr;
797797
}
798798

799-
return memory->is_memory64
800-
? shared_heap->start_off_mem64
801-
: shared_heap->start_off_mem32
802-
+ ((uint8 *)native_addr - shared_heap->base_addr);
799+
return (memory->is_memory64 ? shared_heap->start_off_mem64
800+
: shared_heap->start_off_mem32)
801+
+ (uintptr_t)((uint8 *)native_addr - shared_heap->base_addr);
803802
}
804803

805804
void

core/shared/platform/zephyr/zephyr_file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ os_openat(os_file_handle handle, const char *path, __wasi_oflags_t oflags,
451451
}
452452

453453
if (!build_absolute_path(abs_path, sizeof(abs_path), path)) {
454+
BH_FREE(*out);
454455
return __WASI_ENOMEM;
455456
}
456457

core/shared/utils/bh_queue.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,15 @@ bh_queue_destroy(bh_queue *queue)
9696
bool
9797
bh_post_msg2(bh_queue *queue, bh_queue_node *msg)
9898
{
99+
bh_queue_mutex_lock(&queue->queue_lock);
100+
99101
if (queue->cnt >= queue->max) {
100102
queue->drops++;
101103
bh_free_msg(msg);
104+
bh_queue_mutex_unlock(&queue->queue_lock);
102105
return false;
103106
}
104107

105-
bh_queue_mutex_lock(&queue->queue_lock);
106-
107108
if (queue->cnt == 0) {
108109
bh_assert(queue->head == NULL);
109110
bh_assert(queue->tail == NULL);
@@ -131,7 +132,9 @@ bh_post_msg(bh_queue *queue, unsigned short tag, void *body, unsigned int len)
131132
{
132133
bh_queue_node *msg = bh_new_msg(tag, body, len, NULL);
133134
if (msg == NULL) {
135+
bh_queue_mutex_lock(&queue->queue_lock);
134136
queue->drops++;
137+
bh_queue_mutex_unlock(&queue->queue_lock);
135138
if (len != 0 && body)
136139
BH_FREE(body);
137140
return false;

0 commit comments

Comments
 (0)