]>
git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/compiler-rt/test/asan/TestCases/Darwin/scribble.cc
1 // RUN: %clang_asan -O2 %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck --check-prefix=CHECK-NOSCRIBBLE %s
3 // RUN: %env MallocScribble=1 MallocPreScribble=1 %run %t 2>&1 | FileCheck --check-prefix=CHECK-SCRIBBLE %s
4 // RUN: %env_asan_opts=max_free_fill_size=4096 %run %t 2>&1 | FileCheck --check-prefix=CHECK-SCRIBBLE %s
12 const char *class_name
;
20 void print_my_class_name();
23 __attribute__((no_sanitize("address")))
24 void MyClass::print_my_class_name() {
25 fprintf(stderr
, "this = %p\n", this);
26 fprintf(stderr
, "padding = 0x%lx\n", this->padding
);
27 fprintf(stderr
, "isa = %p\n", this->isa
);
29 if ((uint32_t)(uintptr_t)this->isa
!= 0x55555555) {
30 fprintf(stderr
, "class name: %s\n", this->isa
->class_name
);
35 Isa
*my_class_isa
= (Isa
*)malloc(sizeof(Isa
));
36 memset(my_class_isa
, 0x77, sizeof(Isa
));
37 my_class_isa
->class_name
= "MyClass";
39 MyClass
*my_object
= (MyClass
*)malloc(sizeof(MyClass
));
40 memset(my_object
, 0x88, sizeof(MyClass
));
41 my_object
->isa
= my_class_isa
;
44 my_object
->print_my_class_name();
45 // CHECK-SCRIBBLE: class name: MyClass
46 // CHECK-NOSCRIBBLE: class name: MyClass
50 my_object
->print_my_class_name();
51 // CHECK-NOSCRIBBLE: class name: MyClass
52 // CHECK-SCRIBBLE: isa = {{(0x)?}}{{5555555555555555|55555555}}
54 fprintf(stderr
, "okthxbai!\n");
55 // CHECK-SCRIBBLE: okthxbai!
56 // CHECK-NOSCRIBBLE: okthxbai!