[ASan] Change AddressSanitizer.LoadStoreCallbacks to use asan_malloc and asan_free.

Interceptors don't really work on OSX in asan_noinst_test.cc (this is more or less intentional),
so one shouldn't call intercepted functions in this test -- added a comment about this.

llvm-svn: 206477
This commit is contained in:
Alexander Potapenko 2014-04-17 17:29:07 +00:00
parent c71e7bc415
commit da1c510ea6
1 changed files with 11 additions and 2 deletions

View File

@ -25,6 +25,11 @@
#include <vector>
#include <limits>
// ATTENTION!
// Please don't call intercepted functions (including malloc() and friends)
// in this test. The static runtime library is linked explicitly (without
// -fsanitize=address), thus the interceptors do not work correctly on OS X.
extern "C" {
// Set specific ASan options for uninstrumented unittest.
const char* __asan_default_options() {
@ -233,8 +238,12 @@ TEST(AddressSanitizer, LoadStoreCallbacks) {
uptr buggy_ptr;
__asan_test_only_reported_buggy_pointer = &buggy_ptr;
StackTrace stack;
stack.trace[0] = 0x890;
stack.size = 1;
for (uptr len = 16; len <= 32; len++) {
char *ptr = new char[len];
char *ptr = (char*) __asan::asan_malloc(len, &stack);
uptr p = reinterpret_cast<uptr>(ptr);
for (uptr is_write = 0; is_write <= 1; is_write++) {
for (uptr size_log = 0; size_log <= 4; size_log++) {
@ -251,7 +260,7 @@ TEST(AddressSanitizer, LoadStoreCallbacks) {
}
}
}
delete [] ptr;
__asan::asan_free(ptr, &stack, __asan::FROM_MALLOC);
}
__asan_test_only_reported_buggy_pointer = 0;
}