]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/sanitizer_common/TestCases/Linux/decorate_proc_maps.cc
1 // RUN: %clangxx -g %s -o %t
2 // RUN: %env_tool_opts=decorate_proc_maps=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%tool_name
3 // REQUIRES: stable-runtime
12 bool CopyFdToFd(int in_fd
, int out_fd
) {
13 const size_t kBufSize
= 0x10000;
14 static char buf
[kBufSize
];
16 ssize_t got
= read(in_fd
, buf
, kBufSize
);
18 write(out_fd
, buf
, got
);
19 } else if (got
== 0) {
21 } else if (errno
!= EAGAIN
|| errno
!= EWOULDBLOCK
|| errno
!= EINTR
) {
22 fprintf(stderr
, "error reading file, errno %d\n", errno
);
29 void *ThreadFn(void *arg
) {
31 int fd
= open("/proc/self/maps", O_RDONLY
);
32 bool res
= CopyFdToFd(fd
, 2);
40 pthread_create(&t
, 0, ThreadFn
, 0);
41 pthread_join(t
, &res
);
42 return (int)(size_t)res
;
45 // CHECK-asan: rw-p {{.*}} [low shadow]
46 // CHECK-asan: ---p {{.*}} [shadow gap]
47 // CHECK-asan: rw-p {{.*}} [high shadow]
49 // CHECK-msan: ---p {{.*}} [invalid]
50 // CHECK-msan: rw-p {{.*}} [shadow{{.*}}]
51 // CHECK-msan: ---p {{.*}} [origin{{.*}}]
53 // CHECK-tsan: rw-p {{.*}} [shadow]
54 // CHECK-tsan: rw-p {{.*}} [meta shadow]
55 // CHECK-tsan: rw-p {{.*}} [trace 0]
56 // CHECK-tsan: rw-p {{.*}} [trace header 0]
57 // CHECK-tsan: rw-p {{.*}} [trace 1]
58 // CHECK-tsan: rw-p {{.*}} [trace header 1]
60 // Nothing interesting with standalone LSan.
61 // CHECK-lsan: decorate_proc_maps