diff options
author | Vitaly Buka <vitalybuka@google.com> | 2017-09-23 02:47:21 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2017-09-23 02:47:21 +0000 |
commit | 5b81dfc76eeed0c1a47ac4d5704e70c072887d04 (patch) | |
tree | 70b00361cfb3572ad8f547839bde06fbc4d7099a | |
parent | c3f431fba3c142c03613feee43d9091fa8a128e1 (diff) | |
download | bcm5719-llvm-5b81dfc76eeed0c1a47ac4d5704e70c072887d04.tar.gz bcm5719-llvm-5b81dfc76eeed0c1a47ac4d5704e70c072887d04.zip |
[ubsan] Replace CommonSanitizerReportMutex with ScopedErrorReportLock
Reviewers: eugenis, alekseyshl
Subscribers: kubamracek, llvm-commits
Differential Revision: https://reviews.llvm.org/D38194
llvm-svn: 314053
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_common.h | 2 | ||||
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc | 4 | ||||
-rw-r--r-- | compiler-rt/lib/ubsan/ubsan_diag.cc | 10 | ||||
-rw-r--r-- | compiler-rt/lib/ubsan/ubsan_diag.h | 8 |
4 files changed, 18 insertions, 6 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h index 0c5ea0999b1..a65f732ebe0 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h @@ -213,6 +213,8 @@ class ScopedErrorReportLock { public: ScopedErrorReportLock(); ~ScopedErrorReportLock(); + + static void CheckLocked(); }; extern uptr stoptheworld_tracer_pid; diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc index cce544dd8f3..4048960a0e8 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc @@ -334,6 +334,10 @@ ScopedErrorReportLock::~ScopedErrorReportLock() { atomic_store_relaxed(&reporting_thread, 0); } +void ScopedErrorReportLock::CheckLocked() { + CommonSanitizerReportMutex.CheckLocked(); +} + } // namespace __sanitizer SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_sandbox_on_notify, diff --git a/compiler-rt/lib/ubsan/ubsan_diag.cc b/compiler-rt/lib/ubsan/ubsan_diag.cc index e73fe904235..bc170660c38 100644 --- a/compiler-rt/lib/ubsan/ubsan_diag.cc +++ b/compiler-rt/lib/ubsan/ubsan_diag.cc @@ -337,7 +337,7 @@ static void PrintMemorySnippet(const Decorator &Decor, MemoryLocation Loc, Diag::~Diag() { // All diagnostics should be printed under report mutex. - CommonSanitizerReportMutex.CheckLocked(); + ScopedReport::CheckLocked(); Decorator Decor; InternalScopedString Buffer(1024); @@ -365,17 +365,15 @@ Diag::~Diag() { PrintMemorySnippet(Decor, Loc.getMemoryLocation(), Ranges, NumRanges, Args); } +ScopedReport::Initializer::Initializer() { InitAsStandaloneIfNecessary(); } + ScopedReport::ScopedReport(ReportOptions Opts, Location SummaryLoc, ErrorType Type) - : Opts(Opts), SummaryLoc(SummaryLoc), Type(Type) { - InitAsStandaloneIfNecessary(); - CommonSanitizerReportMutex.Lock(); -} + : Opts(Opts), SummaryLoc(SummaryLoc), Type(Type) {} ScopedReport::~ScopedReport() { MaybePrintStackTrace(Opts.pc, Opts.bp); MaybeReportErrorSummary(SummaryLoc, Type); - CommonSanitizerReportMutex.Unlock(); if (flags()->halt_on_error) Die(); } diff --git a/compiler-rt/lib/ubsan/ubsan_diag.h b/compiler-rt/lib/ubsan/ubsan_diag.h index 2e1983947c6..72b2586285a 100644 --- a/compiler-rt/lib/ubsan/ubsan_diag.h +++ b/compiler-rt/lib/ubsan/ubsan_diag.h @@ -239,6 +239,12 @@ void GetStackTraceWithPcBpAndContext(BufferedStackTrace *stack, uptr max_depth, /// report. This class ensures that reports from different threads and from /// different sanitizers won't be mixed. class ScopedReport { + struct Initializer { + Initializer(); + }; + Initializer initializer_; + ScopedErrorReportLock report_lock_; + ReportOptions Opts; Location SummaryLoc; ErrorType Type; @@ -246,6 +252,8 @@ class ScopedReport { public: ScopedReport(ReportOptions Opts, Location SummaryLoc, ErrorType Type); ~ScopedReport(); + + static void CheckLocked() { ScopedErrorReportLock::CheckLocked(); } }; void InitializeSuppressions(); |