[llvm-commits] [compiler-rt] r148318 - in /compiler-rt/trunk/lib/asan: asan_interceptors.cc tests/asan_test.cc
Kostya Serebryany
kcc at google.com
Tue Jan 17 10:43:53 PST 2012
Author: kcc
Date: Tue Jan 17 12:43:52 2012
New Revision: 148318
URL: http://llvm.org/viewvc/llvm-project?rev=148318&view=rev
Log:
[asan] workaround for bug http://llvm.org/bugs/show_bug.cgi?id=11763. Do not bark on memcpy(a, a, size).
Modified:
compiler-rt/trunk/lib/asan/asan_interceptors.cc
compiler-rt/trunk/lib/asan/tests/asan_test.cc
Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=148318&r1=148317&r2=148318&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Tue Jan 17 12:43:52 2012
@@ -405,7 +405,11 @@
}
ENSURE_ASAN_INITED();
if (FLAG_replace_intrin) {
- CHECK_RANGES_OVERLAP("memcpy", to, size, from, size);
+ if (to != from) {
+ // We do not treat memcpy with to==from as a bug.
+ // See http://llvm.org/bugs/show_bug.cgi?id=11763.
+ CHECK_RANGES_OVERLAP("memcpy", to, size, from, size);
+ }
ASAN_WRITE_RANGE(from, size);
ASAN_READ_RANGE(to, size);
}
Modified: compiler-rt/trunk/lib/asan/tests/asan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test.cc?rev=148318&r1=148317&r2=148318&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_test.cc Tue Jan 17 12:43:52 2012
@@ -1309,8 +1309,11 @@
Ident(memcpy)(str, str, 0);
EXPECT_DEATH(Ident(memcpy)(str, str + 14, 15), OverlapErrorMessage("memcpy"));
EXPECT_DEATH(Ident(memcpy)(str + 14, str, 15), OverlapErrorMessage("memcpy"));
- EXPECT_DEATH(Ident(memcpy)(str + 20, str + 20, 1),
- OverlapErrorMessage("memcpy"));
+
+ // We do not treat memcpy with to==from as a bug.
+ // See http://llvm.org/bugs/show_bug.cgi?id=11763.
+ // EXPECT_DEATH(Ident(memcpy)(str + 20, str + 20, 1),
+ // OverlapErrorMessage("memcpy"));
// Check "strcpy".
memset(str, 'z', size);
@@ -1652,6 +1655,17 @@
EXPECT_EQ(0, munlock((void*)0x987, 0x654));
}
+struct LargeStruct {
+ int foo[100];
+};
+
+// Test for bug http://llvm.org/bugs/show_bug.cgi?id=11763.
+// Struct copy should not cause asan warning even if lhs == rhs.
+TEST(AddressSanitizer, LargeStructCopyTest) {
+ LargeStruct a;
+ *Ident(&a) = *Ident(&a);
+}
+
// ------------------ demo tests; run each one-by-one -------------
// e.g. --gtest_filter=*DemoOOBLeftHigh --gtest_also_run_disabled_tests
TEST(AddressSanitizer, DISABLED_DemoThreadedTest) {
More information about the llvm-commits
mailing list