[compiler-rt] c823cbf - [scudo][Fuchsia] Don't assume MapPlatformData::Vmar is valid

Alex Brachet via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 11 10:41:07 PDT 2022


Author: Alex Brachet
Date: 2022-07-11T17:39:44Z
New Revision: c823cbf699e9324dc1448a46b11941fb3030f97d

URL: https://github.com/llvm/llvm-project/commit/c823cbf699e9324dc1448a46b11941fb3030f97d
DIFF: https://github.com/llvm/llvm-project/commit/c823cbf699e9324dc1448a46b11941fb3030f97d.diff

LOG: [scudo][Fuchsia] Don't assume MapPlatformData::Vmar is valid

After https://reviews.llvm.org/D129237, the assumption
that any non-null data contains a valid vmar handle is no
longer true. Generally this code here needs cleanup, but
in the meantime this fixes errors on Fuchsia.

Differential Revision: https://reviews.llvm.org/D129331

Added: 
    

Modified: 
    compiler-rt/lib/scudo/standalone/fuchsia.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/scudo/standalone/fuchsia.cpp b/compiler-rt/lib/scudo/standalone/fuchsia.cpp
index 8ab2b382a36a..9ec0f85e3486 100644
--- a/compiler-rt/lib/scudo/standalone/fuchsia.cpp
+++ b/compiler-rt/lib/scudo/standalone/fuchsia.cpp
@@ -57,8 +57,7 @@ void *map(void *Addr, uptr Size, const char *Name, uptr Flags,
   if (Flags & MAP_NOACCESS)
     return allocateVmar(Size, Data, AllowNoMem);
 
-  const zx_handle_t Vmar = Data ? Data->Vmar : _zx_vmar_root_self();
-  CHECK_NE(Vmar, ZX_HANDLE_INVALID);
+  const zx_handle_t Vmar = (Data && Data->Vmar != ZX_HANDLE_INVALID) ? Data->Vmar : _zx_vmar_root_self();
 
   zx_status_t Status;
   zx_handle_t Vmo;
@@ -126,7 +125,7 @@ void unmap(void *Addr, uptr Size, uptr Flags, MapPlatformData *Data) {
     CHECK_EQ(_zx_vmar_destroy(Vmar), ZX_OK);
     CHECK_EQ(_zx_handle_close(Vmar), ZX_OK);
   } else {
-    const zx_handle_t Vmar = Data ? Data->Vmar : _zx_vmar_root_self();
+    const zx_handle_t Vmar = (Data && Data->Vmar != ZX_HANDLE_INVALID) ? Data->Vmar : _zx_vmar_root_self();
     const zx_status_t Status =
         _zx_vmar_unmap(Vmar, reinterpret_cast<uintptr_t>(Addr), Size);
     if (UNLIKELY(Status != ZX_OK))


        


More information about the llvm-commits mailing list