Permalink
Browse files

properly handle -fsanitize-blacklist=

  • Loading branch information...
llunak committed Nov 25, 2017
1 parent a693168 commit a2f0d7507c2fb87096c74582d05cdfc05c6e3e40
Showing with 58 additions and 8 deletions.
  1. +14 −4 client/arg.cpp
  2. +1 −1 client/main.cpp
  3. +1 −0 tests/fsanitize-blacklist.txt
  4. +2 −2 tests/fsanitize.cpp
  5. +40 −1 tests/test.sh
@@ -521,18 +521,28 @@ bool analyse_argv(const char * const *argv, CompileJob &job, bool icerun, list<s
} else if (str_equal("-flto", a)) {
// pointless when preprocessing, and Clang would emit a warning
args.append(a, Arg_Remote);
} else if (str_startswith("-fplugin=", a)) {
string file = a + strlen("-fplugin=");
} else if (str_startswith("-fplugin=", a)
|| str_startswith("-fsanitize-blacklist=", a)) {
const char* prefix = NULL;
static const char* const prefixes[] = { "-fplugin=", "-fsanitize-blacklist=" };
for( size_t pref = 0; pref < sizeof(prefixes)/sizeof(prefixes[0]); ++pref) {
if( str_startswith(prefixes[pref], a)) {
prefix = prefixes[pref];
break;
}
}
assert( prefix != NULL );
string file = a + strlen(prefix);
if (access(file.c_str(), R_OK) == 0) {
file = get_absfilename(file);
extrafiles->push_back(file);
} else {
always_local = true;
log_info() << "plugin for argument " << a << " missing, building locally" << endl;
log_info() << "file for argument " << a << " missing, building locally" << endl;
}
args.append("-fplugin=" + file, Arg_Rest);
args.append(prefix + file, Arg_Rest);
} else if (str_equal("-Xclang", a)) {
if (argv[i + 1]) {
++i;
@@ -429,7 +429,7 @@ int main(int argc, char **argv)
// we just build locally
}
} else if (!extrafiles.empty() && !IS_PROTOCOL_32(local_daemon)) {
log_warning() << "Local daemon is too old to handle compiler plugins." << endl;
log_warning() << "Local daemon is too old to handle extra files." << endl;
local = true;
} else {
if (!local_daemon->send_msg(GetNativeEnvMsg(compiler_is_clang(job)
@@ -0,0 +1 @@
fun:*test_fsanitize_function*
@@ -1,4 +1,4 @@
void test()
void test_fsanitize_function()
{
int* arr = new int[10];
delete[] arr;
@@ -8,6 +8,6 @@ void test()
int main()
{
test();
test_fsanitize_function();
return 0;
}
@@ -1018,6 +1018,16 @@ check_log_error()
fi
}
check_section_log_error()
{
log="$1"
if grep -q "$2" "$testdir"/${log}.log "$testdir"/${log}_section.log; then
echo "Error, $log log contains error: $2"
stop_ice 0
abort_tests
fi
}
# check the error message ($2) is not present in log ($1),
# but the exception ($3) is allowed
check_log_error_except()
@@ -1040,6 +1050,16 @@ check_log_message()
fi
}
check_section_log_message()
{
log="$1"
if ! grep -q "$2" "$testdir"/${log}.log "$testdir"/${log}_section.log; then
echo "Error, $log log does not contain: $2"
stop_ice 0
abort_tests
fi
}
check_log_message_count()
{
log="$1"
@@ -1134,8 +1154,27 @@ if $GXX -fsanitize=address -c -fsyntax-only -Werror fsanitize.cpp >/dev/null 2>/
fi
"$testdir"/fsanitize 2>>"$testdir"/stderr.log
check_log_message stderr "ERROR: AddressSanitizer: heap-use-after-free"
check_log_message stderr "SUMMARY: AddressSanitizer: heap-use-after-free .*/fsanitize.cpp:5 in test()"
check_log_message stderr "SUMMARY: AddressSanitizer: heap-use-after-free .*/fsanitize.cpp:5 in test_fsanitize_function()"
rm "$testdir"/fsanitize.o
if $GXX -fsanitize=address -fsanitize-blacklist=fsanitize-blacklist.txt -c -fsyntax-only fsanitize.cpp >/dev/null 2>/dev/null; then
run_ice "" "local" 300 $GXX -c -fsanitize=address -fsanitize-blacklist=nonexistent -g fsanitize.cpp -o "$testdir"/fsanitize.o
check_section_log_message icecc "file for argument -fsanitize-blacklist=nonexistent missing, building locally"
run_ice "$testdir/fsanitize.o" "remote" 0 keepoutput $GXX -c -fsanitize=address -fsanitize-blacklist=fsanitize-blacklist.txt -g fsanitize.cpp -o "$testdir"/fsanitize.o
$GXX -fsanitize=address -fsanitize-blacklist=fsanitize-blacklist.txt -g "$testdir"/fsanitize.o -o "$testdir"/fsanitize 2>>"$testdir"/stderr.log
if test $? -ne 0; then
echo "Linking for -fsanitize test failed."
stop_ice 0
abort_tests
fi
"$testdir"/fsanitize 2>>"$testdir"/stderr.log
check_log_error stderr "ERROR: AddressSanitizer: heap-use-after-free"
check_log_error stderr "SUMMARY: AddressSanitizer: heap-use-after-free .*/fsanitize.cpp:5 in test()"
rm "$testdir"/fsanitize.o
else
skipped_tests="$skipped_tests fsanitize-blacklist"
fi
else
skipped_tests="$skipped_tests fsanitize"
fi

0 comments on commit a2f0d75

Please sign in to comment.