[llvm-commits] [compiler-rt] r153762 - in /compiler-rt/trunk/lib/asan/tests: asan_mac_test.h asan_mac_test.mm asan_test.cc
Alexander Potapenko
glider at google.com
Fri Mar 30 10:31:15 PDT 2012
Author: glider
Date: Fri Mar 30 12:31:15 2012
New Revision: 153762
URL: http://llvm.org/viewvc/llvm-project?rev=153762&view=rev
Log:
Make sure NSObjects are allocated in a way that is visible to ASan.
Modified:
compiler-rt/trunk/lib/asan/tests/asan_mac_test.h
compiler-rt/trunk/lib/asan/tests/asan_mac_test.mm
compiler-rt/trunk/lib/asan/tests/asan_test.cc
Modified: compiler-rt/trunk/lib/asan/tests/asan_mac_test.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_mac_test.h?rev=153762&r1=153761&r2=153762&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_mac_test.h (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_mac_test.h Fri Mar 30 12:31:15 2012
@@ -13,4 +13,5 @@
void TestGCDSourceEvent();
void TestGCDSourceCancel();
void TestGCDGroupAsync();
+ void TestOOBNSObjects();
}
Modified: compiler-rt/trunk/lib/asan/tests/asan_mac_test.mm
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_mac_test.mm?rev=153762&r1=153761&r2=153762&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_mac_test.mm (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_mac_test.mm Fri Mar 30 12:31:15 2012
@@ -205,3 +205,21 @@
});
dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
}
+
+ at interface FixedArray : NSObject {
+ int items[10];
+}
+ at end
+
+ at implementation FixedArray
+-(int) access: (int)index {
+ return items[index];
+}
+ at end
+
+void TestOOBNSObjects() {
+ id anObject = [FixedArray new];
+ [anObject access:1];
+ [anObject access:11];
+ [anObject release];
+}
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=153762&r1=153761&r2=153762&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_test.cc Fri Mar 30 12:31:15 2012
@@ -2023,6 +2023,10 @@
EXPECT_EQ(str, str2);
}
+TEST(AddressSanitizerMac, NSObjectOOB) {
+ // Make sure that our allocators are used for NSObjects.
+ EXPECT_DEATH(TestOOBNSObjects(), "heap-buffer-overflow");
+}
#endif // __APPLE__
// Test that instrumentation of stack allocations takes into account
More information about the llvm-commits
mailing list