[PATCH] D91615: [sanitizer_common] Don't try to unmap unaligned memory

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 17 16:35:06 PST 2020


vitalybuka added inline comments.


================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp:95
     res = (map_res + alignment - 1) & ~(alignment - 1);
-    UnmapOrDie((void*)map_res, res - map_res);
+    if (IsAligned(map_res, GetPageSizeCached()))
+      UnmapOrDie((void*)map_res, res - map_res);
----------------
map_res is just from MMap, it must be aligned?


================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp:99
   uptr end = res + size;
-  if (end != map_end)
+  if (end != map_end && IsAligned(end, GetPageSizeCached()))
     UnmapOrDie((void*)end, map_end - end);
----------------
probably better to align end up to the pagesize


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91615/new/

https://reviews.llvm.org/D91615



More information about the llvm-commits mailing list