-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load supp files with ignores automatically. Activate clang sanitizer by default and ignore it with a warning if clang++ is not installed. Also include timestamp and build commit hash in san logfile. Closed #61 Closed ddnet-insta/ddnet-insta#86
- Loading branch information
1 parent
d9f53b1
commit 6be9712
Showing
6 changed files
with
65 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,62 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
# source lib/env_san.sh | ||
# COMMIT_HASH=yourhash source lib/env_san.sh | ||
|
||
# supp file paths are relative to the bin/ directory | ||
lib_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
export UBSAN_OPTIONS=suppressions=../lib/supp/ubsan.supp:log_path=./SAN:print_stacktrace=1:halt_on_errors=0 | ||
export ASAN_OPTIONS=log_path=./SAN:print_stacktrace=1:check_initialization_order=1:detect_leaks=1:halt_on_errors=0 | ||
export LSAN_OPTIONS=suppressions=../lib/supp/lsan.supp | ||
if [ "$lib_dir" = "" ] | ||
then | ||
echo "Error: failed to get lib dir" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d "$lib_dir" ] | ||
then | ||
echo "Error: lib dir '$lib_dir' is not a directory" | ||
exit 1 | ||
fi | ||
|
||
assert_file() { | ||
[ -f "$1" ] && return | ||
echo "Error: file not found '$1'" | ||
exit 1 | ||
} | ||
|
||
assert_dir() { | ||
[ -d "$1" ] && return | ||
echo "Error: directory not found '$1'" | ||
exit 1 | ||
} | ||
|
||
log_dir="$lib_dir"/../logs | ||
logfile="$log_dir"/SAN_"${COMMIT_HASH:-null}"_"$(date '+%F_%H-%M')" | ||
|
||
assert_file "$lib_dir"/supp/ubsan.supp | ||
assert_file "$lib_dir"/supp/lsan.supp | ||
assert_dir "$log_dir" | ||
|
||
set_vars() { | ||
if [ ! -x "$(command -v clang++)" ] | ||
then | ||
echo "[!] Warning: trying to to use sanitizer env but clang++ is not installed" | ||
echo " check your env_runtime and env_build in your settings.cfg" | ||
echo " make sure clang++ is in PATH" | ||
echo "" | ||
echo " ignoring the current env! The sanitizer will not be activated to avoid build errors" | ||
echo "" | ||
return | ||
fi | ||
|
||
# runtime | ||
export UBSAN_OPTIONS=suppressions="$lib_dir"/supp/ubsan.supp:log_path="$logfile":print_stacktrace=1:halt_on_errors=0 | ||
export ASAN_OPTIONS=log_path="$logfile":print_stacktrace=1:check_initialization_order=1:detect_leaks=1:halt_on_errors=0 | ||
export LSAN_OPTIONS=suppressions="$lib_dir"/supp/lsan.supp | ||
|
||
# compile time | ||
export CC=clang | ||
export CXX=clang++ | ||
export CXXFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" | ||
export CFLAGS="-fsanitize=address,undefined -fsanitize-recover=address,undefined -fno-omit-frame-pointer" | ||
} | ||
|
||
set_vars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters