Skip to content

Commit 1a676f2

Browse files
authored
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
1 parent 06df58f commit 1a676f2

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

core/shared/platform/nuttx/nuttx_platform.c

+14-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
9494

9595
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
9696
if ((prot & MMAP_PROT_EXEC) != 0) {
97-
return up_textheap_memalign(sizeof(void *), size);
97+
p = up_textheap_memalign(sizeof(void *), size);
98+
if (p) {
99+
memset(p, 0, size);
100+
}
101+
return p;
98102
}
99103
#endif
100104

@@ -108,7 +112,11 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
108112
return NULL;
109113
}
110114
i_addr = (void *)((uint8 *)d_addr + MEM_DUAL_BUS_OFFSET);
111-
return in_ibus_ext(i_addr) ? i_addr : d_addr;
115+
p = in_ibus_ext(i_addr) ? i_addr : d_addr;
116+
if (p) {
117+
memset(p, 0, size);
118+
}
119+
return p;
112120
}
113121
#endif
114122
/* 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)
125133
if (posix_memalign(&p, 32, size)) {
126134
return NULL;
127135
}
136+
137+
/* Zero the memory which is required by os_mmap */
138+
memset(p, 0, size);
139+
128140
return p;
129141
}
130142

0 commit comments

Comments
 (0)