Skip to content

Commit 104266b

Browse files
committed
more tests
1 parent e84756e commit 104266b

File tree

4 files changed

+118
-3
lines changed

4 files changed

+118
-3
lines changed

.bazelrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,17 @@ build:tsan --copt -O1
1111
build:tsan --copt -g
1212
build:tsan --copt -fno-omit-frame-pointer
1313
build:tsan --linkopt -fsanitize=thread
14+
15+
build:lsan --strip=never
16+
build:lsan --copt -fsanitize=leak
17+
build:lsan --copt -O1
18+
build:lsan --copt -g
19+
build:lsan --copt -fno-omit-frame-pointer
20+
build:lsan --linkopt -fsanitize=leak
21+
22+
build:ubsan --strip=never
23+
build:ubsan --copt -fsanitize=undefined
24+
build:ubsan --copt -O1
25+
build:ubsan --copt -g
26+
build:ubsan --copt -fno-omit-frame-pointer
27+
build:ubsan --linkopt -fsanitize=undefined

.github/workflows/sanitizers-bazel.yml

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,33 @@ name: sanitizers-bazel
33
on: [push, pull_request]
44

55
jobs:
6-
bazel:
6+
asan:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
os: [ubuntu-latest]
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: bazelbuild/setup-bazelisk@v3
16+
17+
- name: Bazel clean
18+
run: bazel clean
19+
20+
- name: Bazel build
21+
run: bazel build -c dbg --config=asan //...
22+
23+
- name: Bazel test
24+
run: bazel test -c dbg --config=asan --runs_per_test 100 //...
25+
26+
- name: Upload bazel-testlogs
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: bazel-testlogs-asan
30+
path: bazel-testlogs/
31+
32+
tsan:
733
runs-on: ${{ matrix.os }}
834
strategy:
935
matrix:
@@ -26,5 +52,57 @@ jobs:
2652
- name: Upload bazel-testlogs
2753
uses: actions/upload-artifact@v4
2854
with:
29-
name: bazel-testlogs
55+
name: bazel-testlogs-tsan
56+
path: bazel-testlogs/
57+
58+
lsan:
59+
runs-on: ${{ matrix.os }}
60+
strategy:
61+
matrix:
62+
os: [ubuntu-latest]
63+
64+
steps:
65+
- uses: actions/checkout@v4
66+
67+
- uses: bazelbuild/setup-bazelisk@v3
68+
69+
- name: Bazel clean
70+
run: bazel clean
71+
72+
- name: Bazel build
73+
run: bazel build -c dbg --config=lsan //...
74+
75+
- name: Bazel test
76+
run: bazel test -c dbg --config=lsan --runs_per_test 100 //...
77+
78+
- name: Upload bazel-testlogs
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: bazel-testlogs-lsan
82+
path: bazel-testlogs/
83+
84+
ubsan:
85+
runs-on: ${{ matrix.os }}
86+
strategy:
87+
matrix:
88+
os: [ubuntu-latest]
89+
90+
steps:
91+
- uses: actions/checkout@v4
92+
93+
- uses: bazelbuild/setup-bazelisk@v3
94+
95+
- name: Bazel clean
96+
run: bazel clean
97+
98+
- name: Bazel build
99+
run: bazel build -c dbg --config=ubsan //...
100+
101+
- name: Bazel test
102+
run: bazel test -c dbg --config=ubsan --runs_per_test 100 //...
103+
104+
- name: Upload bazel-testlogs
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: bazel-testlogs-ubsan
30108
path: bazel-testlogs/

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,22 @@ elseif (DEBUG_MEMORY STREQUAL "Leak")
585585
set (CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=leak,undefined \
586586
-fno-omit-frame-pointer ")
587587
endif()
588+
elseif (DEBUG_MEMORY STREQUAL "Memory")
589+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
590+
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} \
591+
-fsanitize=memory \
592+
-fno-omit-frame-pointer")
593+
set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} \
594+
-fsanitize=memory \
595+
-fno-omit-frame-pointer")
596+
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=memory \
597+
-fno-omit-frame-pointer ")
598+
set (CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=memory \
599+
-fno-omit-frame-pointer ")
588600

601+
else()
602+
message(FATAL_ERROR "Memory sanitizer only available with clang.")
603+
endif()
589604
endif()
590605

591606
# HiGHS coverage update in progress

check/TestHighsParallel.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,18 @@ int64_t fib(const int64_t n) {
2424
if (n <= 20) return fib_sequential(n);
2525

2626
int64_t n1;
27-
parallel::spawn([&]() { n1 = fib(n - 1); });
27+
parallel::spawn([&]() {
28+
n1 = fib(n - 1);
29+
TSAN_ANNOTATE_HAPPENS_BEFORE(&n1);
30+
});
31+
2832
int64_t n2 = fib(n - 2);
33+
TSAN_ANNOTATE_HAPPENS_BEFORE(&n2);
34+
2935
parallel::sync();
3036

37+
TSAN_ANNOTATE_HAPPENS_AFTER(&n1);
38+
TSAN_ANNOTATE_HAPPENS_AFTER(&n2);
3139
// printf("fib(%ld) = %ld + %ld = %ld\n", n, n1, n2, n1 + n2);
3240
return n1 + n2;
3341
}

0 commit comments

Comments
 (0)