1*7c3d14c8STreehugger Robot // Check that __asan_poison_memory_region works. 2*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s 3*7c3d14c8STreehugger Robot // 4*7c3d14c8STreehugger Robot // Check that we can disable it 5*7c3d14c8STreehugger Robot // RUN: %env_asan_opts=allow_user_poisoning=0 %run %t 6*7c3d14c8STreehugger Robot 7*7c3d14c8STreehugger Robot #include <stdlib.h> 8*7c3d14c8STreehugger Robot 9*7c3d14c8STreehugger Robot extern "C" void __asan_poison_memory_region(void *, size_t); 10*7c3d14c8STreehugger Robot main(int argc,char ** argv)11*7c3d14c8STreehugger Robotint main(int argc, char **argv) { 12*7c3d14c8STreehugger Robot char *x = new char[16]; 13*7c3d14c8STreehugger Robot x[10] = 0; 14*7c3d14c8STreehugger Robot __asan_poison_memory_region(x, 16); 15*7c3d14c8STreehugger Robot int res = x[argc * 10]; // BOOOM 16*7c3d14c8STreehugger Robot // CHECK: ERROR: AddressSanitizer: use-after-poison 17*7c3d14c8STreehugger Robot // CHECK: main{{.*}}use-after-poison.cc:[[@LINE-2]] 18*7c3d14c8STreehugger Robot delete [] x; 19*7c3d14c8STreehugger Robot return res; 20*7c3d14c8STreehugger Robot } 21