diff options
| author | Alexander Potapenko <glider@google.com> | 2012-06-21 16:08:11 +0000 |
|---|---|---|
| committer | Alexander Potapenko <glider@google.com> | 2012-06-21 16:08:11 +0000 |
| commit | 70feed27ea52e0ee97213c14539dd2c62e281c0d (patch) | |
| tree | 3658495b140bded1a7cef21fb20c9fbd8bd6783f | |
| parent | 0e967e01866d025f7d4fe169350bbf8ebafa51d7 (diff) | |
| download | bcm5719-llvm-70feed27ea52e0ee97213c14539dd2c62e281c0d.tar.gz bcm5719-llvm-70feed27ea52e0ee97213c14539dd2c62e281c0d.zip | |
Add a test for issue 81 -- AddressSanitizerMac.DISABLED_CFAllocatorDefaultDoubleFree_ChildPhread
llvm-svn: 158921
| -rw-r--r-- | compiler-rt/lib/asan/tests/asan_mac_test.h | 2 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/tests/asan_mac_test.mm | 3 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/tests/asan_test.cc | 13 |
3 files changed, 15 insertions, 3 deletions
diff --git a/compiler-rt/lib/asan/tests/asan_mac_test.h b/compiler-rt/lib/asan/tests/asan_mac_test.h index 3439ccb05bd..2b194d03c27 100644 --- a/compiler-rt/lib/asan/tests/asan_mac_test.h +++ b/compiler-rt/lib/asan/tests/asan_mac_test.h @@ -1,5 +1,5 @@ extern "C" { - void CFAllocatorDefaultDoubleFree(); + void *CFAllocatorDefaultDoubleFree(void *unused); void CFAllocatorSystemDefaultDoubleFree(); void CFAllocatorMallocDoubleFree(); void CFAllocatorMallocZoneDoubleFree(); diff --git a/compiler-rt/lib/asan/tests/asan_mac_test.mm b/compiler-rt/lib/asan/tests/asan_mac_test.mm index 6ca685685a7..be52b6cd75f 100644 --- a/compiler-rt/lib/asan/tests/asan_mac_test.mm +++ b/compiler-rt/lib/asan/tests/asan_mac_test.mm @@ -9,7 +9,8 @@ #import <Foundation/NSObject.h> #import <Foundation/NSURL.h> -void CFAllocatorDefaultDoubleFree() { +// This is a (void*)(void*) function so it can be passed to pthread_create. +void *CFAllocatorDefaultDoubleFree(void *unused) { void *mem = CFAllocatorAllocate(kCFAllocatorDefault, 5, 0); CFAllocatorDeallocate(kCFAllocatorDefault, mem); CFAllocatorDeallocate(kCFAllocatorDefault, mem); diff --git a/compiler-rt/lib/asan/tests/asan_test.cc b/compiler-rt/lib/asan/tests/asan_test.cc index bbccd21ee0e..aa4a19be91d 100644 --- a/compiler-rt/lib/asan/tests/asan_test.cc +++ b/compiler-rt/lib/asan/tests/asan_test.cc @@ -1902,10 +1902,20 @@ TEST(AddressSanitizer, BufferOverflowAfterManyFrees) { #include "asan_mac_test.h" TEST(AddressSanitizerMac, CFAllocatorDefaultDoubleFree) { EXPECT_DEATH( - CFAllocatorDefaultDoubleFree(), + CFAllocatorDefaultDoubleFree(NULL), "attempting double-free"); } +void CFAllocator_DoubleFreeOnPthread() { + pthread_t child; + pthread_create(&child, NULL, CFAllocatorDefaultDoubleFree, NULL); + pthread_join(child, NULL); // Shouldn't be reached. +} + +TEST(AddressSanitizerMac, DISABLED_CFAllocatorDefaultDoubleFree_ChildPhread) { + EXPECT_DEATH(CFAllocator_DoubleFreeOnPthread(), "attempting double-free"); +} + // TODO(glider): figure out whether we still need these tests. Is it correct // to intercept the non-default CFAllocators? TEST(AddressSanitizerMac, DISABLED_CFAllocatorSystemDefaultDoubleFree) { @@ -1914,6 +1924,7 @@ TEST(AddressSanitizerMac, DISABLED_CFAllocatorSystemDefaultDoubleFree) { "attempting double-free"); } +// We're intercepting malloc, so kCFAllocatorMalloc is routed to ASan. TEST(AddressSanitizerMac, CFAllocatorMallocDoubleFree) { EXPECT_DEATH(CFAllocatorMallocDoubleFree(), "attempting double-free"); } |

