1 // This test program creates a very large number of unique histories.
3 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -m64 -O3 %s -o %t
5 // RUN: MSAN_OPTIONS=origin_history_size=7 not %run %t >%t.out 2>&1
6 // RUN: FileCheck %s --check-prefix=CHECK7 < %t.out
8 // RUN: MSAN_OPTIONS=origin_history_size=2 not %run %t >%t.out 2>&1
9 // RUN: FileCheck %s --check-prefix=CHECK2 < %t.out
11 // RUN: MSAN_OPTIONS=origin_history_per_stack_limit=1 not %run %t >%t.out 2>&1
12 // RUN: FileCheck %s --check-prefix=CHECK-PER-STACK < %t.out
19 static char *buf
, *cur
, *end
;
28 for (p
= cur
- 1; p
>= buf
; --p
)
32 size_t write_sz
= p
- buf
+ 1;
33 // write(2, buf, write_sz);
34 memmove(buf
, p
+ 1, end
- p
- 1);
39 void buffered_write(const char *p
, size_t sz
) {
41 size_t copy_sz
= end
- cur
;
42 if (sz
< copy_sz
) copy_sz
= sz
;
43 memcpy(cur
, p
, copy_sz
);
51 buffered_write("a\n", 2);
55 buffered_write("a\n", 2);
59 buffered_write("a\n", 2);
64 for (int i
= 0; i
< 2000; ++i
) {
72 // CHECK7: WARNING: MemorySanitizer: use-of-uninitialized-value
73 // CHECK7-NOT: Uninitialized value was stored to memory at
74 // CHECK7: Uninitialized value was stored to memory at
75 // CHECK7-NOT: Uninitialized value was stored to memory at
76 // CHECK7: Uninitialized value was stored to memory at
77 // CHECK7-NOT: Uninitialized value was stored to memory at
78 // CHECK7: Uninitialized value was stored to memory at
79 // CHECK7-NOT: Uninitialized value was stored to memory at
80 // CHECK7: Uninitialized value was stored to memory at
81 // CHECK7-NOT: Uninitialized value was stored to memory at
82 // CHECK7: Uninitialized value was stored to memory at
83 // CHECK7-NOT: Uninitialized value was stored to memory at
84 // CHECK7: Uninitialized value was stored to memory at
85 // CHECK7-NOT: Uninitialized value was stored to memory at
86 // CHECK7: Uninitialized value was created by a heap allocation
88 // CHECK2: WARNING: MemorySanitizer: use-of-uninitialized-value
89 // CHECK2-NOT: Uninitialized value was stored to memory at
90 // CHECK2: Uninitialized value was stored to memory at
91 // CHECK2-NOT: Uninitialized value was stored to memory at
92 // CHECK2: Uninitialized value was created by a heap allocation
94 // CHECK-PER-STACK: WARNING: MemorySanitizer: use-of-uninitialized-value
95 // CHECK-PER-STACK: Uninitialized value was stored to memory at
96 // CHECK-PER-STACK: in fn3
97 // CHECK-PER-STACK: Uninitialized value was stored to memory at
98 // CHECK-PER-STACK: in fn2
99 // CHECK-PER-STACK: Uninitialized value was stored to memory at
100 // CHECK-PER-STACK: in fn1
101 // CHECK-PER-STACK: Uninitialized value was created by a heap allocation