diff options
Diffstat (limited to 'lib/tsan/output_tests/heap_race.cc')
-rw-r--r-- | lib/tsan/output_tests/heap_race.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/tsan/output_tests/heap_race.cc b/lib/tsan/output_tests/heap_race.cc new file mode 100644 index 0000000..e92bb37 --- /dev/null +++ b/lib/tsan/output_tests/heap_race.cc @@ -0,0 +1,19 @@ +#include <pthread.h> +#include <stdio.h> +#include <stddef.h> + +void *Thread(void *a) { + ((int*)a)[0]++; + return NULL; +} + +int main() { + int *p = new int(42); + pthread_t t; + pthread_create(&t, NULL, Thread, p); + p[0]++; + pthread_join(t, NULL); + delete p; +} + +// CHECK: WARNING: ThreadSanitizer: data race |