diff --git a/config/external/wasm2c_sandbox_compiler/moz.yaml b/config/external/wasm2c_sandbox_compiler/moz.yaml
index 08d82ccb441769dadd04f674ca119912e0459fa9..b5152260a7fb5e2bbb1e157f4111ccc42b961a7f 100644
--- a/config/external/wasm2c_sandbox_compiler/moz.yaml
+++ b/config/external/wasm2c_sandbox_compiler/moz.yaml
@@ -9,8 +9,8 @@ origin:
   description: wasm2c fork used for rlbox sandboxing
   url: https://github.com/PLSysSec/wasm2c_sandbox_compiler
 
-  release: commit e78e291be785e7f6bf442ba16127e4cb666f8882 (2021-09-02T04:47:14Z).
-  revision: e78e291be785e7f6bf442ba16127e4cb666f8882
+  release: commit 551fd0e7d8f0349562d4402bc626a689e7ecde4f (2021-09-09T00:19:32Z).
+  revision: 551fd0e7d8f0349562d4402bc626a689e7ecde4f
 
   license: Apache-2.0
   license-file: LICENSE
diff --git a/third_party/wasm2c/wasm2c/wasm-rt-impl.c b/third_party/wasm2c/wasm2c/wasm-rt-impl.c
index 42173c0f246f3d1fdce4edbf053b700caae9537c..2be22f2c8af03ceddab8357c88d5756f4d7d78eb 100644
--- a/third_party/wasm2c/wasm2c/wasm-rt-impl.c
+++ b/third_party/wasm2c/wasm2c/wasm-rt-impl.c
@@ -134,7 +134,7 @@ void wasm_rt_allocate_memory(wasm_rt_memory_t* memory,
   }
 
   if (!addr) {
-    perror("mmap failed");
+    os_print_last_error("os_mmap failed.");
     abort();
   }
   int ret = os_mmap_commit(addr, byte_length, MMAP_PROT_READ | MMAP_PROT_WRITE);
diff --git a/third_party/wasm2c/wasm2c/wasm-rt-os-unix.c b/third_party/wasm2c/wasm2c/wasm-rt-os-unix.c
index 52b3ca30ef05b8111abdba2d1ef533fa7311eadd..39749a39beb75d3d24a33a0c27780f463fbd5c46 100644
--- a/third_party/wasm2c/wasm2c/wasm-rt-os-unix.c
+++ b/third_party/wasm2c/wasm2c/wasm-rt-os-unix.c
@@ -268,6 +268,10 @@ int os_clock_getres(void* clock_data, int clock_id, struct timespec* out_struct)
   return ret;
 }
 
+void os_print_last_error(const char* msg) {
+  perror(msg);
+}
+
 #undef VERBOSE_LOG
 
 #else
diff --git a/third_party/wasm2c/wasm2c/wasm-rt-os-win.c b/third_party/wasm2c/wasm2c/wasm-rt-os-win.c
index 53d847b4976feb1f113e875ed82497c16cb483d0..6c733d3f94bc186301c74c78f5dccee240684ecf 100644
--- a/third_party/wasm2c/wasm2c/wasm-rt-os-win.c
+++ b/third_party/wasm2c/wasm2c/wasm-rt-os-win.c
@@ -276,6 +276,22 @@ int os_clock_getres(void* clock_data, int clock_id, struct timespec* out_struct)
   return 0;
 }
 
+void os_print_last_error(const char* msg) {
+  DWORD errorMessageID  = GetLastError();
+  if (errorMessageID != 0) {
+    LPSTR messageBuffer = 0;
+    //The api creates the buffer that holds the message
+    size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+                                NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, NULL);
+    (void) size;
+    //Copy the error message into a std::string.
+    printf("%s. %s\n", msg, messageBuffer);
+    LocalFree(messageBuffer);
+  } else {
+    printf("%s. No error code.\n", msg);
+  }
+}
+
 #undef VERBOSE_LOG
 #undef DONT_USE_VIRTUAL_ALLOC2
 
diff --git a/third_party/wasm2c/wasm2c/wasm-rt-os.h b/third_party/wasm2c/wasm2c/wasm-rt-os.h
index 45cf9995c5a047b15f8393b864c56fc95b8475ac..ad36f3bbe0e99069a2ea341c3b4fc716603e2169 100644
--- a/third_party/wasm2c/wasm2c/wasm-rt-os.h
+++ b/third_party/wasm2c/wasm2c/wasm-rt-os.h
@@ -43,4 +43,7 @@ void os_clock_cleanup(void** clock_data_pointer);
 int os_clock_gettime(void* clock_data, int clock_id, struct timespec* out_struct);
 int os_clock_getres(void* clock_data, int clock_id, struct timespec* out_struct);
 
+// print the error message
+void os_print_last_error(const char* msg);
+
 #endif
diff --git a/third_party/wasm2c/wasm2c/wasm-rt-wasi.c b/third_party/wasm2c/wasm2c/wasm-rt-wasi.c
index 698ff73b46bdfbcf27df41e8e0a0e54cf3b7cbb3..d87499aea2f70b13f3a332c908ca380a1f5abc6a 100644
--- a/third_party/wasm2c/wasm2c/wasm-rt-wasi.c
+++ b/third_party/wasm2c/wasm2c/wasm-rt-wasi.c
@@ -740,7 +740,7 @@ u32 Z_wasi_snapshot_preview1Z_clock_time_getZ_iiji(wasm_sandbox_wasi_data* wasi_
 
   struct timespec out_struct;
   int ret = os_clock_gettime(wasi_data->clock_data, clock_id, &out_struct);
-  u64 result = ((u64)out_struct.tv_sec)*1000000 + ((u64)out_struct.tv_nsec)/1000;
+  u64 result = ((u64)out_struct.tv_sec)*1000*1000*1000 + ((u64)out_struct.tv_nsec);
   wasm_i64_store(wasi_data->heap_memory, out, result);
   return ret;
 }
@@ -752,7 +752,7 @@ u32 Z_wasi_snapshot_preview1Z_clock_res_getZ_iii(wasm_sandbox_wasi_data* wasi_da
 
   struct timespec out_struct;
   int ret = os_clock_getres(wasi_data->clock_data, clock_id, &out_struct);
-  u64 result = ((u64)out_struct.tv_sec)*1000000 + ((u64)out_struct.tv_nsec)/1000;
+  u64 result = ((u64)out_struct.tv_sec)*1000*1000*1000 + ((u64)out_struct.tv_nsec);
   wasm_i64_store(wasi_data->heap_memory, out, result);
   return ret;
 }