1 // Checks that the __sanitizer_on_print hook gets the exact same sanitizer
2 // report as what is printed to stderr.
4 // RUN: %clangxx %s -o %t
5 // RUN: %run %t %t-onprint.txt 2>%t-stderr.txt || true
6 // RUN: diff %t-onprint.txt %t-stderr.txt
8 // UNSUPPORTED: android
15 #include <sys/types.h>
22 __attribute__((disable_sanitizer_instrumentation
)) extern "C" void
23 __sanitizer_on_print(const char *str
) {
24 write(f
, str
, strlen(str
));
27 int main(int argc
, char *argv
[]) {
29 f
= open(argv
[1], O_CREAT
| O_TRUNC
| O_WRONLY
, 0666);
31 // Use-after-free to trigger ASan/TSan reports.
32 void *ptr
= malloc(1);
35 sink
= *static_cast<char *>(ptr
);