summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFilipe Cabecinhas <me@filcab.net>2016-09-15 08:10:56 +0000
committerFilipe Cabecinhas <me@filcab.net>2016-09-15 08:10:56 +0000
commit1e567a616bc127fee5319a9b0e4e14b3b5e8f195 (patch)
tree5bd97c7c496952df5b98abdb558e61aea72e1d09 /lib
parenta64e60426b09bf97529144cc264fe29ee18a942c (diff)
downloadcompiler-rt-1e567a616bc127fee5319a9b0e4e14b3b5e8f195.tar.gz
[asan] Reify ErrorInvalidPointerPair
Summary: Continue work on PR30351 Reviewers: vitalybuka, kcc, eugenis Subscribers: kubabrecka, llvm-commits Differential Revision: https://reviews.llvm.org/D24554 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281593 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/asan/asan_errors.cc13
-rw-r--r--lib/asan/asan_errors.h14
-rw-r--r--lib/asan/asan_report.cc16
3 files changed, 30 insertions, 13 deletions
diff --git a/lib/asan/asan_errors.cc b/lib/asan/asan_errors.cc
index 55481ff1b..b84773496 100644
--- a/lib/asan/asan_errors.cc
+++ b/lib/asan/asan_errors.cc
@@ -267,4 +267,17 @@ void ErrorODRViolation::Print() {
ReportErrorSummary(error_msg.data());
}
+void ErrorInvalidPointerPair::Print() {
+ const char *bug_type = "invalid-pointer-pair";
+ Decorator d;
+ Printf("%s", d.Warning());
+ Report("ERROR: AddressSanitizer: invalid-pointer-pair: %p %p\n", p1, p2);
+ Printf("%s", d.EndWarning());
+ GET_STACK_TRACE_FATAL(pc, bp);
+ stack.Print();
+ PrintAddressDescription(p1, 1, bug_type);
+ PrintAddressDescription(p2, 1, bug_type);
+ ReportErrorSummary(bug_type, &stack);
+}
+
} // namespace __asan
diff --git a/lib/asan/asan_errors.h b/lib/asan/asan_errors.h
index 5f02a71eb..57062dd0a 100644
--- a/lib/asan/asan_errors.h
+++ b/lib/asan/asan_errors.h
@@ -278,6 +278,17 @@ struct ErrorODRViolation : ErrorBase {
void Print();
};
+struct ErrorInvalidPointerPair : ErrorBase {
+ uptr pc, bp, sp, p1, p2;
+ // VS2013 doesn't implement unrestricted unions, so we need a trivial default
+ // constructor
+ ErrorInvalidPointerPair() = default;
+ ErrorInvalidPointerPair(u32 tid, uptr pc_, uptr bp_, uptr sp_, uptr p1_,
+ uptr p2_)
+ : ErrorBase(tid), pc(pc_), bp(bp_), sp(sp_), p1(p1_), p2(p2_) {}
+ void Print();
+};
+
// clang-format off
#define ASAN_FOR_EACH_ERROR_KIND(macro) \
macro(StackOverflow) \
@@ -291,7 +302,8 @@ struct ErrorODRViolation : ErrorBase {
macro(StringFunctionMemoryRangesOverlap) \
macro(StringFunctionSizeOverflow) \
macro(BadParamsToAnnotateContiguousContainer) \
- macro(ODRViolation)
+ macro(ODRViolation) \
+ macro(InvalidPointerPair)
// clang-format on
#define ASAN_DEFINE_ERROR_KIND(name) kErrorKind##name,
diff --git a/lib/asan/asan_report.cc b/lib/asan/asan_report.cc
index 0f9ac1c51..f71b85c16 100644
--- a/lib/asan/asan_report.cc
+++ b/lib/asan/asan_report.cc
@@ -414,19 +414,11 @@ void ReportODRViolation(const __asan_global *g1, u32 stack_id1,
}
// ----------------------- CheckForInvalidPointerPair ----------- {{{1
-static NOINLINE void
-ReportInvalidPointerPair(uptr pc, uptr bp, uptr sp, uptr a1, uptr a2) {
+static NOINLINE void ReportInvalidPointerPair(uptr pc, uptr bp, uptr sp,
+ uptr a1, uptr a2) {
ScopedInErrorReport in_report;
- const char *bug_type = "invalid-pointer-pair";
- Decorator d;
- Printf("%s", d.Warning());
- Report("ERROR: AddressSanitizer: invalid-pointer-pair: %p %p\n", a1, a2);
- Printf("%s", d.EndWarning());
- GET_STACK_TRACE_FATAL(pc, bp);
- stack.Print();
- PrintAddressDescription(a1, 1, bug_type);
- PrintAddressDescription(a2, 1, bug_type);
- ReportErrorSummary(bug_type, &stack);
+ ErrorInvalidPointerPair error(GetCurrentTidOrInvalid(), pc, bp, sp, a1, a2);
+ in_report.ReportError(error);
}
static INLINE void CheckForInvalidPointerPair(void *p1, void *p2) {