[llvm-commits] [compiler-rt] r158843 - in /compiler-rt/trunk/lib/asan/tests: asan_mac_test.h asan_mac_test.mm asan_test.cc

Alexander Potapenko glider at google.com
Wed Jun 20 13:28:39 PDT 2012


Author: glider
Date: Wed Jun 20 15:28:39 2012
New Revision: 158843

URL: http://llvm.org/viewvc/llvm-project?rev=158843&view=rev
Log:
Add a test for NSURL deallocation (issue 70)


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=158843&r1=158842&r2=158843&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_mac_test.h (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_mac_test.h Wed Jun 20 15:28:39 2012
@@ -14,4 +14,5 @@
   void TestGCDSourceCancel();
   void TestGCDGroupAsync();
   void TestOOBNSObjects();
+  void TestNSURLDeallocation();
 }

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=158843&r1=158842&r2=158843&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_mac_test.mm (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_mac_test.mm Wed Jun 20 15:28:39 2012
@@ -7,6 +7,7 @@
 
 #import <CoreFoundation/CFBase.h>
 #import <Foundation/NSObject.h>
+#import <Foundation/NSURL.h>
 
 void CFAllocatorDefaultDoubleFree() {
   void *mem =  CFAllocatorAllocate(kCFAllocatorDefault, 5, 0);
@@ -223,3 +224,12 @@
   [anObject access:11];
   [anObject release];
 }
+
+void TestNSURLDeallocation() {
+  NSURL *base =
+      [[NSURL alloc] initWithString:@"file://localhost/Users/glider/Library/"];
+  volatile NSURL *u =
+      [[NSURL alloc] initWithString:@"Saved Application State"
+                     relativeToURL:base];
+  [u 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=158843&r1=158842&r2=158843&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_test.cc Wed Jun 20 15:28:39 2012
@@ -2049,6 +2049,13 @@
   // Make sure that our allocators are used for NSObjects.
   EXPECT_DEATH(TestOOBNSObjects(), "heap-buffer-overflow");
 }
+
+// Make sure that correct pointer is passed to free() when deallocating a
+// NSURL object.
+// See http://code.google.com/p/address-sanitizer/issues/detail?id=70.
+TEST(AddressSanitizerMac, DISABLED_NSURLDeallocation) {
+  TestNSURLDeallocation();
+}
 #endif  // __APPLE__
 
 // Test that instrumentation of stack allocations takes into account





More information about the llvm-commits mailing list