[PATCH] D18003: [tsan] Disable randomized address space on linux.
Yabin Cui via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 10 14:13:43 PST 2016
yabinc updated this revision to Diff 50352.
yabinc added a comment.
Limit columns to < 80.
http://reviews.llvm.org/D18003
Files:
lib/tsan/rtl/tsan_platform_linux.cc
Index: lib/tsan/rtl/tsan_platform_linux.cc
===================================================================
--- lib/tsan/rtl/tsan_platform_linux.cc
+++ lib/tsan/rtl/tsan_platform_linux.cc
@@ -36,6 +36,7 @@
#include <string.h>
#include <stdarg.h>
#include <sys/mman.h>
+#include <sys/personality.h>
#include <sys/syscall.h>
#include <sys/socket.h>
#include <sys/time.h>
@@ -263,6 +264,20 @@
#endif
}
+static uptr GetHeapEnd() {
+ MemoryMappingLayout proc_maps(true);
+ uptr heap_end = 0;
+ uptr start, end, prot;
+ while (proc_maps.Next(&start, &end, 0, 0, 0, &prot)) {
+ // Omit stack
+ if (start <= (uptr)&heap_end && (uptr)&heap_end < end)
+ continue;
+ if (end > heap_end)
+ heap_end = end;
+ }
+ return heap_end;
+}
+
void InitializePlatform() {
DisableCoreDumperIfNecessary();
@@ -291,6 +306,17 @@
SetAddressSpaceUnlimited();
reexec = true;
}
+ int old_personality = personality(0xffffffff);
+ if (old_personality != -1 && (old_personality & ADDR_NO_RANDOMIZE) == 0) {
+ if (GetHeapEnd() < HeapMemEnd()) {
+ Report("WARNING: Program is run with randomized virtual address space,"
+ " and uses heap space out of that assumed by ThreadSanitizer."
+ "\n");
+ Report("Re-execing with fixed virtual address space.\n");
+ CHECK(personality(old_personality | ADDR_NO_RANDOMIZE) != -1);
+ reexec = true;
+ }
+ }
if (reexec)
ReExec();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18003.50352.patch
Type: text/x-patch
Size: 1486 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160310/e52deb38/attachment.bin>
More information about the llvm-commits
mailing list