]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/msan/chained_origin_limits.cc
1 // This test program creates a very large number of unique histories.
4 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O3 %s -o %t
6 // RUN: MSAN_OPTIONS=origin_history_size=7 not %run %t >%t.out 2>&1
7 // RUN: FileCheck %s --check-prefix=CHECK7 < %t.out
9 // RUN: MSAN_OPTIONS=origin_history_size=2 not %run %t >%t.out 2>&1
10 // RUN: FileCheck %s --check-prefix=CHECK2 < %t.out
12 // RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
13 // RUN: FileCheck %s --check-prefix=CHECK-PER-STACK < %t.out
15 // RUN: MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
16 // RUN: FileCheck %s --check-prefix=CHECK7 < %t.out
19 // RUN: %clangxx_msan -DSTACK -fsanitize-memory-track-origins=2 -O3 %s -o %t
21 // RUN: MSAN_OPTIONS=origin_history_size=7 not %run %t >%t.out 2>&1
22 // RUN: FileCheck %s --check-prefix=CHECK7 < %t.out
24 // RUN: MSAN_OPTIONS=origin_history_size=2 not %run %t >%t.out 2>&1
25 // RUN: FileCheck %s --check-prefix=CHECK2 < %t.out
27 // RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
28 // RUN: FileCheck %s --check-prefix=CHECK-PER-STACK < %t.out
30 // RUN: MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
31 // RUN: FileCheck %s --check-prefix=CHECK7 < %t.out
34 // Heap origin, with calls.
35 // RUN: %clangxx_msan -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -O3 %s -o %t
37 // RUN: MSAN_OPTIONS=origin_history_size=7 not %run %t >%t.out 2>&1
38 // RUN: FileCheck %s --check-prefix=CHECK7 < %t.out
40 // RUN: MSAN_OPTIONS=origin_history_size=2 not %run %t >%t.out 2>&1
41 // RUN: FileCheck %s --check-prefix=CHECK2 < %t.out
43 // RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
44 // RUN: FileCheck %s --check-prefix=CHECK-PER-STACK < %t.out
46 // RUN: MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
47 // RUN: FileCheck %s --check-prefix=CHECK7 < %t.out
50 // Stack origin, with calls.
51 // RUN: %clangxx_msan -DSTACK -mllvm -msan-instrumentation-with-call-threshold=0 -fsanitize-memory-track-origins=2 -O3 %s -o %t
53 // RUN: MSAN_OPTIONS=origin_history_size=7 not %run %t >%t.out 2>&1
54 // RUN: FileCheck %s --check-prefix=CHECK7 < %t.out
56 // RUN: MSAN_OPTIONS=origin_history_size=2 not %run %t >%t.out 2>&1
57 // RUN: FileCheck %s --check-prefix=CHECK2 < %t.out
59 // RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
60 // RUN: FileCheck %s --check-prefix=CHECK-PER-STACK < %t.out
62 // RUN: MSAN_OPTIONS=origin_history_size=7,origin_history_per_stack_limit=0 not %run %t >%t.out 2>&1
63 // RUN: FileCheck %s --check-prefix=CHECK7 < %t.out
70 static char *buf
, *cur
, *end
;
75 char *volatile p
= stackbuf
;
84 for (p
= cur
- 1; p
>= buf
; --p
)
88 size_t write_sz
= p
- buf
+ 1;
89 // write(2, buf, write_sz);
90 memmove(buf
, p
+ 1, end
- p
- 1);
95 void buffered_write(const char *p
, size_t sz
) {
97 size_t copy_sz
= end
- cur
;
98 if (sz
< copy_sz
) copy_sz
= sz
;
99 memcpy(cur
, p
, copy_sz
);
107 buffered_write("a\n", 2);
111 buffered_write("a\n", 2);
115 buffered_write("a\n", 2);
120 for (int i
= 0; i
< 2000; ++i
) {
128 // CHECK7: WARNING: MemorySanitizer: use-of-uninitialized-value
129 // CHECK7-NOT: Uninitialized value was stored to memory at
130 // CHECK7: Uninitialized value was stored to memory at
131 // CHECK7-NOT: Uninitialized value was stored to memory at
132 // CHECK7: Uninitialized value was stored to memory at
133 // CHECK7-NOT: Uninitialized value was stored to memory at
134 // CHECK7: Uninitialized value was stored to memory at
135 // CHECK7-NOT: Uninitialized value was stored to memory at
136 // CHECK7: Uninitialized value was stored to memory at
137 // CHECK7-NOT: Uninitialized value was stored to memory at
138 // CHECK7: Uninitialized value was stored to memory at
139 // CHECK7-NOT: Uninitialized value was stored to memory at
140 // CHECK7: Uninitialized value was stored to memory at
141 // CHECK7-NOT: Uninitialized value was stored to memory at
142 // CHECK7: Uninitialized value was created
144 // CHECK2: WARNING: MemorySanitizer: use-of-uninitialized-value
145 // CHECK2-NOT: Uninitialized value was stored to memory at
146 // CHECK2: Uninitialized value was stored to memory at
147 // CHECK2-NOT: Uninitialized value was stored to memory at
148 // CHECK2: Uninitialized value was created
150 // CHECK-PER-STACK: WARNING: MemorySanitizer: use-of-uninitialized-value
151 // CHECK-PER-STACK: Uninitialized value was stored to memory at
152 // CHECK-PER-STACK: in fn3
153 // CHECK-PER-STACK: Uninitialized value was stored to memory at
154 // CHECK-PER-STACK: in fn2
155 // CHECK-PER-STACK: Uninitialized value was stored to memory at
156 // CHECK-PER-STACK: in fn1
157 // CHECK-PER-STACK: Uninitialized value was created
159 // CHECK-UNLIMITED: WARNING: MemorySanitizer: use-of-uninitialized-value
160 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
161 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
162 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
163 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
164 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
165 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
166 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
167 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
168 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
169 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
170 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
171 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
172 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
173 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
174 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
175 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
176 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
177 // CHECK-UNLIMITED: Uninitialized value was stored to memory at
178 // CHECK-UNLIMITED: Uninitialized value was created