summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2015-01-02 09:59:38 +0000
committerChandler Carruth <chandlerc@gmail.com>2015-01-02 09:59:38 +0000
commitee2d9890ccbda9ef229eeacc8ede3dd365284f4c (patch)
tree61127c2352ab74528d01fcbf2853ece9ada6eec3
parent45f2ae8d28fc3cfc5d7f1da604fa620c3e09a809 (diff)
Revert r224736: "[Sanitizer] Make CommonFlags immutable after initialization."
We've got some internal users that either aren't compatible with this or have found a bug with it. Either way, this is an isolated cleanup and so I'm reverting it to un-block folks while we investigate. Alexey and I will be working on fixing everything up so this can be re-committed soon. Sorry for the noise and any inconvenience. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@225079 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/asan/asan_flags.cc20
-rw-r--r--lib/lsan/lsan_common.cc9
-rw-r--r--lib/msan/msan.cc17
-rw-r--r--lib/sanitizer_common/sanitizer_flags.h12
-rw-r--r--lib/tsan/dd/dd_rtl.cc9
-rw-r--r--lib/tsan/rtl/tsan_flags.cc18
-rw-r--r--lib/ubsan/ubsan_flags.cc5
7 files changed, 33 insertions, 57 deletions
diff --git a/lib/asan/asan_flags.cc b/lib/asan/asan_flags.cc
index 7db1f020c..4099de205 100644
--- a/lib/asan/asan_flags.cc
+++ b/lib/asan/asan_flags.cc
@@ -172,15 +172,13 @@ void ParseFlagsFromString(Flags *f, const char *str) {
}
void InitializeFlags(Flags *f) {
+ CommonFlags *cf = common_flags();
SetCommonFlagsDefaults();
- {
- CommonFlags cf = *common_flags();
- cf.detect_leaks = CAN_SANITIZE_LEAKS;
- cf.external_symbolizer_path = GetEnv("ASAN_SYMBOLIZER_PATH");
- cf.malloc_context_size = kDefaultMallocContextSize;
- cf.intercept_tls_get_addr = true;
- OverrideCommonFlags(cf);
- }
+ cf->detect_leaks = CAN_SANITIZE_LEAKS;
+ cf->external_symbolizer_path = GetEnv("ASAN_SYMBOLIZER_PATH");
+ cf->malloc_context_size = kDefaultMallocContextSize;
+ cf->intercept_tls_get_addr = true;
+ cf->coverage = false;
internal_memset(f, 0, sizeof(*f));
f->quarantine_size = (ASAN_LOW_MEMORY) ? 1UL << 26 : 1UL << 28;
@@ -260,17 +258,17 @@ void InitializeFlags(Flags *f) {
}
// Flag validation:
- if (!CAN_SANITIZE_LEAKS && common_flags()->detect_leaks) {
+ if (!CAN_SANITIZE_LEAKS && cf->detect_leaks) {
Report("%s: detect_leaks is not supported on this platform.\n",
SanitizerToolName);
- Die();
+ cf->detect_leaks = false;
}
// Make "strict_init_order" imply "check_initialization_order".
// TODO(samsonov): Use a single runtime flag for an init-order checker.
if (f->strict_init_order) {
f->check_initialization_order = true;
}
- CHECK_LE((uptr)common_flags()->malloc_context_size, kStackTraceMax);
+ CHECK_LE((uptr)cf->malloc_context_size, kStackTraceMax);
CHECK_LE(f->min_uar_stack_size_log, f->max_uar_stack_size_log);
CHECK_GE(f->redzone, 16);
CHECK_GE(f->max_redzone, f->redzone);
diff --git a/lib/lsan/lsan_common.cc b/lib/lsan/lsan_common.cc
index 3d4d8a6ab..89fef773b 100644
--- a/lib/lsan/lsan_common.cc
+++ b/lib/lsan/lsan_common.cc
@@ -74,13 +74,12 @@ static void InitializeFlags(bool standalone) {
// Set defaults for common flags (only in standalone mode) and parse
// them from LSAN_OPTIONS.
+ CommonFlags *cf = common_flags();
if (standalone) {
SetCommonFlagsDefaults();
- CommonFlags cf = *common_flags();
- cf.external_symbolizer_path = GetEnv("LSAN_SYMBOLIZER_PATH");
- cf.malloc_context_size = 30;
- cf.detect_leaks = true;
- OverrideCommonFlags(cf);
+ cf->external_symbolizer_path = GetEnv("LSAN_SYMBOLIZER_PATH");
+ cf->malloc_context_size = 30;
+ cf->detect_leaks = true;
}
ParseCommonFlagsFromString(options);
}
diff --git a/lib/msan/msan.cc b/lib/msan/msan.cc
index 4925619ec..546ffa719 100644
--- a/lib/msan/msan.cc
+++ b/lib/msan/msan.cc
@@ -144,17 +144,14 @@ static void ParseFlagsFromString(Flags *f, const char *str) {
}
static void InitializeFlags(Flags *f, const char *options) {
+ CommonFlags *cf = common_flags();
SetCommonFlagsDefaults();
- {
- CommonFlags cf = *common_flags();
- cf.external_symbolizer_path = GetEnv("MSAN_SYMBOLIZER_PATH");
- cf.malloc_context_size = 20;
- cf.handle_ioctl = true;
- // FIXME: test and enable.
- cf.check_printf = false;
- cf.intercept_tls_get_addr = true;
- OverrideCommonFlags(cf);
- }
+ cf->external_symbolizer_path = GetEnv("MSAN_SYMBOLIZER_PATH");
+ cf->malloc_context_size = 20;
+ cf->handle_ioctl = true;
+ // FIXME: test and enable.
+ cf->check_printf = false;
+ cf->intercept_tls_get_addr = true;
internal_memset(f, 0, sizeof(*f));
f->poison_heap_with_zeroes = false;
diff --git a/lib/sanitizer_common/sanitizer_flags.h b/lib/sanitizer_common/sanitizer_flags.h
index 8718089ae..f71cf43b2 100644
--- a/lib/sanitizer_common/sanitizer_flags.h
+++ b/lib/sanitizer_common/sanitizer_flags.h
@@ -73,7 +73,7 @@ struct CommonFlags {
// Functions to get/set global CommonFlags shared by all sanitizer runtimes:
extern CommonFlags common_flags_dont_use;
-inline const CommonFlags *common_flags() {
+inline CommonFlags *common_flags() {
return &common_flags_dont_use;
}
@@ -84,16 +84,6 @@ inline void SetCommonFlagsDefaults() {
inline void ParseCommonFlagsFromString(const char *str) {
common_flags_dont_use.ParseFromString(str);
}
-
-// This function can only be used to setup tool-specific overrides for
-// CommonFlags defaults. Generally, it should only be used right after
-// SetCommonFlagsDefaults(), but before ParseCommonFlagsFromString(), and
-// only during the flags initialization (i.e. before they are used for
-// the first time).
-inline void OverrideCommonFlags(const CommonFlags &cf) {
- common_flags_dont_use = cf;
-}
-
void PrintFlagDescriptions();
} // namespace __sanitizer
diff --git a/lib/tsan/dd/dd_rtl.cc b/lib/tsan/dd/dd_rtl.cc
index 3fd893dfb..cc8e5a0c4 100644
--- a/lib/tsan/dd/dd_rtl.cc
+++ b/lib/tsan/dd/dd_rtl.cc
@@ -70,13 +70,10 @@ void InitializeFlags(Flags *f, const char *env) {
// Default values.
f->second_deadlock_stack = false;
+ CommonFlags *cf = common_flags();
SetCommonFlagsDefaults();
- {
- // Override some common flags defaults.
- CommonFlags cf = *common_flags();
- cf.allow_addr2line = true;
- OverrideCommonFlags(cf);
- }
+ // Override some common flags defaults.
+ cf->allow_addr2line = true;
// Override from command line.
ParseFlag(env, &f->second_deadlock_stack, "second_deadlock_stack", "");
diff --git a/lib/tsan/rtl/tsan_flags.cc b/lib/tsan/rtl/tsan_flags.cc
index 70fa1808a..ec74a24b0 100644
--- a/lib/tsan/rtl/tsan_flags.cc
+++ b/lib/tsan/rtl/tsan_flags.cc
@@ -93,16 +93,13 @@ void InitializeFlags(Flags *f, const char *env) {
// DDFlags
f->second_deadlock_stack = false;
+ CommonFlags *cf = common_flags();
SetCommonFlagsDefaults();
- {
- // Override some common flags defaults.
- CommonFlags cf = *common_flags();
- cf.allow_addr2line = true;
- cf.detect_deadlocks = true;
- cf.print_suppressions = false;
- cf.stack_trace_format = " #%n %f %S %M";
- OverrideCommonFlags(cf);
- }
+ // Override some common flags defaults.
+ cf->allow_addr2line = true;
+ cf->detect_deadlocks = true;
+ cf->print_suppressions = false;
+ cf->stack_trace_format = " #%n %f %S %M";
// Let a frontend override.
ParseFlags(f, __tsan_default_options());
@@ -118,8 +115,7 @@ void InitializeFlags(Flags *f, const char *env) {
f->report_signal_unsafe = false;
}
- if (common_flags()->help)
- PrintFlagDescriptions();
+ if (cf->help) PrintFlagDescriptions();
if (f->history_size < 0 || f->history_size > 7) {
Printf("ThreadSanitizer: incorrect value for history_size"
diff --git a/lib/ubsan/ubsan_flags.cc b/lib/ubsan/ubsan_flags.cc
index 61e703cde..db0e29bb2 100644
--- a/lib/ubsan/ubsan_flags.cc
+++ b/lib/ubsan/ubsan_flags.cc
@@ -22,10 +22,9 @@ static const char *MaybeCallUbsanDefaultOptions() {
}
void InitializeCommonFlags() {
+ CommonFlags *cf = common_flags();
SetCommonFlagsDefaults();
- CommonFlags cf = *common_flags();
- cf.print_summary = false;
- OverrideCommonFlags(cf);
+ cf->print_summary = false;
// Override from user-specified string.
ParseCommonFlagsFromString(MaybeCallUbsanDefaultOptions());
// Override from environment variable.