[compiler-rt] r199715 - [asan] relax the checks inside __sanitizer_annotate_contiguous_container: they are too optimistic due to https://code.google.com/p/address-sanitizer/issues/detail?id=258.

Kostya Serebryany kcc at google.com
Tue Jan 21 01:53:50 PST 2014


Author: kcc
Date: Tue Jan 21 03:53:49 2014
New Revision: 199715

URL: http://llvm.org/viewvc/llvm-project?rev=199715&view=rev
Log:
[asan] relax the checks inside __sanitizer_annotate_contiguous_container: they are too optimistic due to https://code.google.com/p/address-sanitizer/issues/detail?id=258.

Modified:
    compiler-rt/trunk/lib/asan/asan_poisoning.cc
    compiler-rt/trunk/lib/asan/lit_tests/TestCases/contiguous_container.cc

Modified: compiler-rt/trunk/lib/asan/asan_poisoning.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_poisoning.cc?rev=199715&r1=199714&r2=199715&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_poisoning.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_poisoning.cc Tue Jan 21 03:53:49 2014
@@ -284,17 +284,20 @@ void __sanitizer_annotate_contiguous_con
   uptr a = RoundDownTo(Min(old_mid, new_mid), granularity);
   uptr c = RoundUpTo(Max(old_mid, new_mid), granularity);
   uptr d1 = RoundDownTo(old_mid, granularity);
-  uptr d2 = RoundUpTo(old_mid, granularity);
+  // uptr d2 = RoundUpTo(old_mid, granularity);
   // Currently we should be in this state:
   // [a, d1) is good, [d2, c) is bad, [d1, d2) is partially good.
   // Make a quick sanity check that we are indeed in this state.
-  if (d1 != d2)
-    CHECK_EQ(*(u8*)MemToShadow(d1), old_mid - d1);
+  //
+  // FIXME: Two of these three checks are disabled until we fix
+  // https://code.google.com/p/address-sanitizer/issues/detail?id=258.
+  // if (d1 != d2)
+  //  CHECK_EQ(*(u8*)MemToShadow(d1), old_mid - d1);
   if (a + granularity <= d1)
     CHECK_EQ(*(u8*)MemToShadow(a), 0);
-  if (d2 + granularity <= c && c <= end)
-    CHECK_EQ(*(u8 *)MemToShadow(c - granularity),
-             kAsanContiguousContainerOOBMagic);
+  // if (d2 + granularity <= c && c <= end)
+  //   CHECK_EQ(*(u8 *)MemToShadow(c - granularity),
+  //            kAsanContiguousContainerOOBMagic);
 
   uptr b1 = RoundDownTo(new_mid, granularity);
   uptr b2 = RoundUpTo(new_mid, granularity);

Modified: compiler-rt/trunk/lib/asan/lit_tests/TestCases/contiguous_container.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/TestCases/contiguous_container.cc?rev=199715&r1=199714&r2=199715&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/TestCases/contiguous_container.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/TestCases/contiguous_container.cc Tue Jan 21 03:53:49 2014
@@ -40,8 +40,35 @@ void TestContainer(size_t capacity) {
   delete[] beg;
 }
 
+__attribute__((noinline))
+void Throw() { throw 1; }
+
+__attribute__((noinline))
+void ThrowAndCatch() {
+  try {
+    Throw();
+  } catch(...) {
+  }
+}
+
+void TestThrow() {
+  char x[32];
+  __sanitizer_annotate_contiguous_container(x, x + 32, x + 32, x + 14);
+  assert(!__asan_address_is_poisoned(x + 13));
+  assert(__asan_address_is_poisoned(x + 14));
+  ThrowAndCatch();
+  assert(!__asan_address_is_poisoned(x + 13));
+  // FIXME: invert the assertion below once we fix
+  // https://code.google.com/p/address-sanitizer/issues/detail?id=258
+  assert(!__asan_address_is_poisoned(x + 14));
+  __sanitizer_annotate_contiguous_container(x, x + 32, x + 14, x + 32);
+  assert(!__asan_address_is_poisoned(x + 13));
+  assert(!__asan_address_is_poisoned(x + 14));
+}
+
 int main(int argc, char **argv) {
   int n = argc == 1 ? 128 : atoi(argv[1]);
   for (int i = 0; i <= n; i++)
     TestContainer(i);
+  TestThrow();
 }





More information about the llvm-commits mailing list