[ASan] Enable the new and delete wrappers on Darwin.
Also fix large_func_test.cc, which got broken when we switched to allocator2: the OOB access was too far from the original allocation, so ASan decided to describe the next one. llvm-svn: 174626
This commit is contained in:
parent
aba500d633
commit
4fb43438d9
|
@ -27,9 +27,9 @@ void ReplaceOperatorsNewAndDelete() { }
|
|||
|
||||
using namespace __asan; // NOLINT
|
||||
|
||||
// On Mac and Android new() goes through malloc interceptors.
|
||||
// On Android new() goes through malloc interceptors.
|
||||
// See also https://code.google.com/p/address-sanitizer/issues/detail?id=131.
|
||||
#if !ASAN_ANDROID && !ASAN_MAC
|
||||
#if !ASAN_ANDROID
|
||||
|
||||
// Fake std::nothrow_t to avoid including <new>.
|
||||
namespace std {
|
||||
|
|
|
@ -32,7 +32,7 @@ static void LargeFunction(int *x, int zero) {
|
|||
// CHECK: {{.*ERROR: AddressSanitizer: heap-buffer-overflow on address}}
|
||||
// CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
|
||||
// CHECK: {{READ of size 4 at 0x.* thread T0}}
|
||||
x[zero + 111]++; // we should report this exact line
|
||||
x[zero + 103]++; // we should report this exact line
|
||||
// atos incorrectly extracts the symbol name for the static functions on
|
||||
// Darwin.
|
||||
// CHECK-Linux: {{#0 0x.* in LargeFunction.*large_func_test.cc:}}[[@LINE-3]]
|
||||
|
@ -54,14 +54,9 @@ int main(int argc, char **argv) {
|
|||
int *x = new int[100];
|
||||
LargeFunction(x, argc - 1);
|
||||
// CHECK: {{ #1 0x.* in _?main .*large_func_test.cc:}}[[@LINE-1]]
|
||||
// CHECK: {{0x.* is located 44 bytes to the right of 400-byte region}}
|
||||
// CHECK: {{0x.* is located 12 bytes to the right of 400-byte region}}
|
||||
// CHECK: {{allocated by thread T0 here:}}
|
||||
// CHECK-Linux: {{ #0 0x.* in operator new.*}}
|
||||
// CHECK-Linux: {{ #1 0x.* in _?main .*large_func_test.cc:}}[[@LINE-6]]
|
||||
|
||||
// CHECK-Darwin: {{ #0 0x.* in _?wrap_malloc.*}}
|
||||
// CHECK-Darwin: {{ #1 0x.* in operator new.*}}
|
||||
// CHECK-Darwin: {{ #2 0x.* in operator new\[\].*}}
|
||||
// CHECK-Darwin: {{ #3 0x.* in _?main .*large_func_test.cc:}}[[@LINE-11]]
|
||||
// CHECK: {{ #0 0x.* in operator new.*}}
|
||||
// CHECK: {{ #1 0x.* in _?main .*large_func_test.cc:}}[[@LINE-6]]
|
||||
delete x;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue