summaryrefslogtreecommitdiff
path: root/lib/msan
diff options
context:
space:
mode:
authorAlexey Samsonov <vonosmas@gmail.com>2015-08-21 20:49:37 +0000
committerAlexey Samsonov <vonosmas@gmail.com>2015-08-21 20:49:37 +0000
commit23b3d26ca5e3f782373f73620d7872dc0fc1c0b2 (patch)
treec0cc0f0de1a49054359e7b85e7f3d1fb6eeef180 /lib/msan
parent564ca11c1e257ea6207a50bbfe36be4ecc29fe5f (diff)
[Sanitizers] Unify the semantics and usage of "exitcode" runtime flag across all sanitizers.
Summary: Merge "exitcode" flag from ASan, LSan, TSan and "exit_code" from MSan into one entity. Additionally, make sure sanitizer_common now uses the value of common_flags()->exitcode when dying on error, so that this flag will automatically work for other sanitizers (UBSan and DFSan) as well. User-visible changes: * "exit_code" MSan runtime flag is now deprecated. If explicitly specified, this flag will take precedence over "exitcode". The users are encouraged to migrate to the new version. * __asan_set_error_exit_code() and __msan_set_exit_code() functions are removed. With few exceptions, we don't support changing runtime flags during program execution - we can't make them thread-safe. The users should use __sanitizer_set_death_callback() that would call _exit() with proper exit code instead. * Plugin tools (LSan and UBSan) now inherit the exit code of the parent tool. In particular, this means that ASan would now crash the program with exit code "1" instead of "23" if it detects leaks. Reviewers: kcc, eugenis Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D12120 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245734 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/msan')
-rw-r--r--lib/msan/msan.cc20
-rw-r--r--lib/msan/msan_flags.inc3
-rw-r--r--lib/msan/msan_interface_internal.h6
-rw-r--r--lib/msan/msan_linux.cc4
4 files changed, 17 insertions, 16 deletions
diff --git a/lib/msan/msan.cc b/lib/msan/msan.cc
index d75c280ad..1d2767d8d 100644
--- a/lib/msan/msan.cc
+++ b/lib/msan/msan.cc
@@ -145,6 +145,7 @@ static void InitializeFlags() {
// FIXME: test and enable.
cf.check_printf = false;
cf.intercept_tls_get_addr = true;
+ cf.exitcode = 77;
OverrideCommonFlags(cf);
}
@@ -185,11 +186,18 @@ static void InitializeFlags() {
if (common_flags()->help) parser.PrintFlagDescriptions();
- // Check flag values:
- if (f->exit_code < 0 || f->exit_code > 127) {
- Printf("Exit code not in [0, 128) range: %d\n", f->exit_code);
- Die();
+ // Check if deprecated exit_code MSan flag is set.
+ if (f->exit_code != -1) {
+ if (Verbosity())
+ Printf("MSAN_OPTIONS=exit_code is deprecated! "
+ "Please use MSAN_OPTIONS=exitcode instead.\n");
+ CommonFlags cf;
+ cf.CopyFrom(*common_flags());
+ cf.exitcode = f->exit_code;
+ OverrideCommonFlags(cf);
}
+
+ // Check flag values:
if (f->origin_history_size < 0 ||
f->origin_history_size > Origin::kMaxDepth) {
Printf(
@@ -421,10 +429,6 @@ void __msan_init() {
msan_inited = 1;
}
-void __msan_set_exit_code(int exit_code) {
- flags()->exit_code = exit_code;
-}
-
void __msan_set_keep_going(int keep_going) {
flags()->halt_on_error = !keep_going;
}
diff --git a/lib/msan/msan_flags.inc b/lib/msan/msan_flags.inc
index 3729b3fc4..a7ff6c586 100644
--- a/lib/msan/msan_flags.inc
+++ b/lib/msan/msan_flags.inc
@@ -17,7 +17,8 @@
// MSAN_FLAG(Type, Name, DefaultValue, Description)
// See COMMON_FLAG in sanitizer_flags.inc for more details.
-MSAN_FLAG(int, exit_code, 77, "")
+MSAN_FLAG(int, exit_code, -1,
+ "DEPRECATED. Use exitcode from common flags instead.")
MSAN_FLAG(int, origin_history_size, Origin::kMaxDepth, "")
MSAN_FLAG(int, origin_history_per_stack_limit, 20000, "")
MSAN_FLAG(bool, poison_heap_with_zeroes, false, "")
diff --git a/lib/msan/msan_interface_internal.h b/lib/msan/msan_interface_internal.h
index 3b0e30c56..7340a34ca 100644
--- a/lib/msan/msan_interface_internal.h
+++ b/lib/msan/msan_interface_internal.h
@@ -27,7 +27,7 @@ SANITIZER_INTERFACE_ATTRIBUTE
void __msan_init();
// Print a warning and maybe return.
-// This function can die based on flags()->exit_code.
+// This function can die based on common_flags()->exitcode.
SANITIZER_INTERFACE_ATTRIBUTE
void __msan_warning();
@@ -106,10 +106,6 @@ int __msan_origin_is_descendant_or_same(u32 this_id, u32 prev_id);
SANITIZER_INTERFACE_ATTRIBUTE
void __msan_clear_on_return();
-// Default: -1 (don't exit on error).
-SANITIZER_INTERFACE_ATTRIBUTE
-void __msan_set_exit_code(int exit_code);
-
SANITIZER_INTERFACE_ATTRIBUTE
void __msan_set_keep_going(int keep_going);
diff --git a/lib/msan/msan_linux.cc b/lib/msan/msan_linux.cc
index 7025ef6c8..9e971994d 100644
--- a/lib/msan/msan_linux.cc
+++ b/lib/msan/msan_linux.cc
@@ -156,7 +156,6 @@ void MsanDie() {
__sanitizer_cov_dump();
if (death_callback)
death_callback();
- internal__exit(flags()->exit_code);
}
static void MsanAtExit(void) {
@@ -164,7 +163,8 @@ static void MsanAtExit(void) {
ReportStats();
if (msan_report_count > 0) {
ReportAtExitStatistics();
- if (flags()->exit_code) _exit(flags()->exit_code);
+ if (common_flags()->exitcode)
+ internal__exit(common_flags()->exitcode);
}
}