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

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 4 03:57:20 PST 2022


ro added a comment.

Sorry for dropping the ball on this one: the revised patch is trivial.  I've now tested it (together with D91827 <https://reviews.llvm.org/D91827> which is necessary to make the test `PASS`) on `sparcv9-sun-solaris2.11`, `amd64-pc-solaris2.11`, and `x86_64-pc-linux-gnu`.



================
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);
----------------
vitalybuka wrote:
> map_res is just from MMap, it must be aligned?
It is indeed: this snippet is unnecessary.


================
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);
----------------
vitalybuka wrote:
> probably better to align end up to the pagesize
Right, patch amended accordingly.


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