[compiler-rt] r206952 - tsan: more precise check for "app memory" in COMPAT mode
Dmitry Vyukov
dvyukov at google.com
Wed Apr 23 00:01:02 PDT 2014
Author: dvyukov
Date: Wed Apr 23 02:01:02 2014
New Revision: 206952
URL: http://llvm.org/viewvc/llvm-project?rev=206952&view=rev
Log:
tsan: more precise check for "app memory" in COMPAT mode
this fires when a user makes mmap with fixed address (see the test)
Added:
compiler-rt/trunk/test/tsan/mmap_large.cc
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h?rev=206952&r1=206951&r2=206952&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform.h Wed Apr 23 02:01:02 2014
@@ -77,6 +77,8 @@ static const uptr kLinuxShadowMsk = 0x20
#elif defined(TSAN_COMPAT_SHADOW) && TSAN_COMPAT_SHADOW
static const uptr kLinuxAppMemBeg = 0x290000000000ULL;
static const uptr kLinuxAppMemEnd = 0x7fffffffffffULL;
+static const uptr kAppMemGapBeg = 0x2c0000000000ULL;
+static const uptr kAppMemGapEnd = 0x7d0000000000ULL;
#else
static const uptr kLinuxAppMemBeg = 0x7cf000000000ULL;
static const uptr kLinuxAppMemEnd = 0x7fffffffffffULL;
@@ -105,7 +107,12 @@ static const uptr kLinuxShadowEnd =
MemToShadow(kLinuxAppMemEnd) | 0xff;
static inline bool IsAppMem(uptr mem) {
+#if defined(TSAN_COMPAT_SHADOW) && TSAN_COMPAT_SHADOW
+ return (mem >= kLinuxAppMemBeg && mem < kAppMemGapBeg) ||
+ (mem >= kAppMemGapEnd && mem <= kLinuxAppMemEnd);
+#else
return mem >= kLinuxAppMemBeg && mem <= kLinuxAppMemEnd;
+#endif
}
static inline bool IsShadowMem(uptr mem) {
Added: compiler-rt/trunk/test/tsan/mmap_large.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/tsan/mmap_large.cc?rev=206952&view=auto
==============================================================================
--- compiler-rt/trunk/test/tsan/mmap_large.cc (added)
+++ compiler-rt/trunk/test/tsan/mmap_large.cc Wed Apr 23 02:01:02 2014
@@ -0,0 +1,19 @@
+// RUN: %clang_tsan -O1 %s -o %t && %t 2>&1 | FileCheck %s
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/mman.h>
+
+int main() {
+ const size_t kLog2Size = 40;
+ const uintptr_t kLocation = 0x40ULL << kLog2Size;
+ void *p = mmap(
+ reinterpret_cast<void*>(kLocation),
+ 1ULL << kLog2Size,
+ PROT_READ|PROT_WRITE,
+ MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE,
+ -1, 0);
+ fprintf(stderr, "DONE %p\n", p);
+ return p == MAP_FAILED;
+}
+
+// CHECK: DONE
More information about the llvm-commits
mailing list