From 1a676f212bcedad0c0bd766ae694a412a6cdce17 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Mon, 5 Feb 2024 15:45:22 +0800 Subject: [PATCH] Zero the memory mapped from os_mmap in NuttX (#3132) Zero the memory which is required by os_mmap. This fixes the nuttx spec test CI failure: https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/7777804669 --- core/shared/platform/nuttx/nuttx_platform.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core/shared/platform/nuttx/nuttx_platform.c b/core/shared/platform/nuttx/nuttx_platform.c index d105924ae..0077c9e02 100644 --- a/core/shared/platform/nuttx/nuttx_platform.c +++ b/core/shared/platform/nuttx/nuttx_platform.c @@ -94,7 +94,11 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) #if defined(CONFIG_ARCH_USE_TEXT_HEAP) if ((prot & MMAP_PROT_EXEC) != 0) { - return up_textheap_memalign(sizeof(void *), size); + p = up_textheap_memalign(sizeof(void *), size); + if (p) { + memset(p, 0, size); + } + return p; } #endif @@ -108,7 +112,11 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) return NULL; } i_addr = (void *)((uint8 *)d_addr + MEM_DUAL_BUS_OFFSET); - return in_ibus_ext(i_addr) ? i_addr : d_addr; + p = in_ibus_ext(i_addr) ? i_addr : d_addr; + if (p) { + memset(p, 0, size); + } + return p; } #endif /* Note: aot_loader.c assumes that os_mmap provides large enough @@ -125,6 +133,10 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) if (posix_memalign(&p, 32, size)) { return NULL; } + + /* Zero the memory which is required by os_mmap */ + memset(p, 0, size); + return p; }