Changeset View
Changeset View
Standalone View
Standalone View
compiler-rt/trunk/test/asan/TestCases/Linux/cuda_test.cc
// Emulate the behavior of the NVIDIA CUDA driver | // Emulate the behavior of the NVIDIA CUDA driver | ||||
// that mmaps memory inside the asan's shadow gap. | // that mmaps memory inside the asan's shadow gap. | ||||
// | // | ||||
// REQUIRES: x86_64-target-arch | // REQUIRES: x86_64-target-arch, shadow-scale-3 | ||||
// | // | ||||
// RUN: %clangxx_asan %s -o %t | // RUN: %clangxx_asan %s -o %t | ||||
// RUN: not %env_asan_opts=protect_shadow_gap=1 %t 2>&1 | FileCheck %s --check-prefix=CHECK-PROTECT1 | // RUN: not %env_asan_opts=protect_shadow_gap=1 %t 2>&1 | FileCheck %s --check-prefix=CHECK-PROTECT1 | ||||
// RUN: not %t 2>&1 | FileCheck %s --check-prefix=CHECK-PROTECT1 | // RUN: not %t 2>&1 | FileCheck %s --check-prefix=CHECK-PROTECT1 | ||||
// RUN: not %env_asan_opts=protect_shadow_gap=0 %t 2>&1 | FileCheck %s --check-prefix=CHECK-PROTECT0 | // RUN: not %env_asan_opts=protect_shadow_gap=0 %t 2>&1 | FileCheck %s --check-prefix=CHECK-PROTECT0 | ||||
#include <assert.h> | #include <assert.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <sys/mman.h> | #include <sys/mman.h> | ||||
Show All 15 Lines | int main(void) { | ||||
// CHECK-PROTECT1: AddressSanitizer: SEGV on unknown address 0x0000bfff8000 | // CHECK-PROTECT1: AddressSanitizer: SEGV on unknown address 0x0000bfff8000 | ||||
// Poison a part of gap's shadow: | // Poison a part of gap's shadow: | ||||
__asan_poison_memory_region((void*)Base, 4096); | __asan_poison_memory_region((void*)Base, 4096); | ||||
// Now we should fail with use-after-poison. | // Now we should fail with use-after-poison. | ||||
*(char*)(Base + 1234) = 1; | *(char*)(Base + 1234) = 1; | ||||
// CHECK-PROTECT0: AddressSanitizer: use-after-poison on address 0x0002000004d2 | // CHECK-PROTECT0: AddressSanitizer: use-after-poison on address 0x0002000004d2 | ||||
} | } | ||||