Просмотр исходного кода

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
Huang Qi 1 год назад
Родитель
Сommit
1a676f212b
1 измененных файлов с 14 добавлено и 2 удалено
  1. 14 2
      core/shared/platform/nuttx/nuttx_platform.c

+ 14 - 2
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;
 }