Skip to content

Commit b6fb4ec

Browse files
committed
Move thread sanitizer example
Put into a subdirectory, and the file/app/test renamed to what is expected to occur, a data race.
1 parent ce64152 commit b6fb4ec

File tree

3 files changed

+15
-24
lines changed

3 files changed

+15
-24
lines changed

example/all/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ if(EXAMPLE_USE_SANITIZER)
5353
endif()
5454

5555
# Fails with ThreadSanitizer
56-
add_executable(tsanFail ../src/tsan_fail.cpp)
57-
target_code_coverage(tsanFail AUTO ALL)
56+
add_executable(tsan_data_race ../src/tsan/data_race.cpp)
57+
target_code_coverage(tsan_data_race AUTO ALL)
5858
if(UNIX)
59-
target_link_libraries(tsanFail PUBLIC pthread)
59+
target_link_libraries(tsan_data_race PUBLIC pthread)
6060
endif()
61-
add_test(tsan tsanFail)
61+
add_test(tsan_data_race tsan_data_race)
6262

6363
# Fails with LeakSanitizer
6464
add_executable(lsan_direct_leak ../src/lsan/direct_leak.c)

example/src/tsan/data_race.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdio.h>
2+
#include <thread>
3+
4+
void threadfunc(int *p) { *p = 1; }
5+
6+
int main() {
7+
int val = 0;
8+
std::thread t(threadfunc, &val);
9+
printf("foo=%i\n", val);
10+
t.join();
11+
}

example/src/tsan_fail.cpp

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)