Skip to content

Commit ba3395b

Browse files
committed
generic asan check
1 parent 088a531 commit ba3395b

2 files changed

Lines changed: 33 additions & 29 deletions

File tree

lib/lib.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,38 @@ function get_cores() {
112112
echo "$cores"
113113
}
114114

115+
is_asan_runtime() {
116+
if printf '%s' "$CFG_ENV_RUNTIME" | grep -qE '(env_san.sh|fsanitize)'
117+
then
118+
return 0
119+
fi
120+
return 1
121+
}
122+
123+
is_asan_build() {
124+
if printf '%s' "$CFG_ENV_BUILD" | grep -qE '(env_san.sh|fsanitize)'
125+
then
126+
return 0
127+
fi
128+
return 1
129+
}
130+
131+
die_if_asan_on_because() {
132+
local conflicting_tool="$1"
133+
if is_asan_runtime || is_asan_build
134+
then
135+
err "Error: in your server.cnf you enabled a sanitizer already"
136+
err " $conflicting_tool does not work well when combined with asan and ubsan"
137+
err " go to your server.cnf and check where you set env_build and env_runtime"
138+
err " their current values are:"
139+
err ""
140+
err " env_build=$CFG_ENV_BUILD"
141+
err " env_runtime=$CFG_ENV_RUNTIME"
142+
err ""
143+
exit 1
144+
fi
145+
}
146+
115147
function save_move() {
116148
if [[ ! -f "$1" ]]
117149
then

valgrind.sh

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -52,35 +52,7 @@ check_running
5252
install_dep valgrind
5353
archive_gmon
5454
restart_side_runner
55-
56-
is_asan_runtime() {
57-
if printf '%s' "$CFG_ENV_RUNTIME" | grep -qE '(env_san.sh|fsanitize)'
58-
then
59-
return 0
60-
fi
61-
return 1
62-
}
63-
64-
is_asan_build() {
65-
if printf '%s' "$CFG_ENV_BUILD" | grep -qE '(env_san.sh|fsanitize)'
66-
then
67-
return 0
68-
fi
69-
return 1
70-
}
71-
72-
if is_asan_runtime || is_asan_build
73-
then
74-
err "Error: in your server.cnf you enabled a sanitizer already"
75-
err " valgrind does not work well when combined with asan and ubsan"
76-
err " go to your server.cnf and check where you set env_build and env_runtime"
77-
err " their current values are:"
78-
err ""
79-
err " env_build=$CFG_ENV_BUILD"
80-
err " env_runtime=$CFG_ENV_RUNTIME"
81-
err ""
82-
exit 1
83-
fi
55+
die_if_asan_on_because valgrind
8456

8557
export COMMIT_HASH
8658
if ! COMMIT_HASH="$(get_commit)"

0 commit comments

Comments
 (0)