mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-09 01:29:52 +00:00
233f401c2b
Add a script that is used to deflake inherently flaky tsan tests. It is invoked from lit tests as: %deflake %run %t The script runs the target program up to 10 times, until it produces a tsan warning. llvm-svn: 209898
27 lines
594 B
C
27 lines
594 B
C
// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
|
|
#include <stdlib.h>
|
|
|
|
void __attribute__((noinline)) foo(int *mem) {
|
|
free(mem);
|
|
}
|
|
|
|
void __attribute__((noinline)) bar(int *mem) {
|
|
mem[0] = 42;
|
|
}
|
|
|
|
int main() {
|
|
int *mem = (int*)malloc(100);
|
|
foo(mem);
|
|
bar(mem);
|
|
return 0;
|
|
}
|
|
|
|
// CHECK: WARNING: ThreadSanitizer: heap-use-after-free
|
|
// CHECK: Write of size 4 at {{.*}} by main thread:
|
|
// CHECK: #0 bar
|
|
// CHECK: #1 main
|
|
// CHECK: Previous write of size 8 at {{.*}} by main thread:
|
|
// CHECK: #0 free
|
|
// CHECK: #{{1|2}} foo
|
|
// CHECK: #{{2|3}} main
|