forked from OSchip/llvm-project
[asan] Reify ErrorInvalidPointerPair
Summary: Continue work on PR30351 Reviewers: vitalybuka, kcc, eugenis Subscribers: kubabrecka, llvm-commits Differential Revision: https://reviews.llvm.org/D24554 llvm-svn: 281593
This commit is contained in:
parent
719db0c0c5
commit
1b3742eb8f
|
|
@ -267,4 +267,17 @@ void ErrorODRViolation::Print() {
|
||||||
ReportErrorSummary(error_msg.data());
|
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
|
} // namespace __asan
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,17 @@ struct ErrorODRViolation : ErrorBase {
|
||||||
void Print();
|
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
|
// clang-format off
|
||||||
#define ASAN_FOR_EACH_ERROR_KIND(macro) \
|
#define ASAN_FOR_EACH_ERROR_KIND(macro) \
|
||||||
macro(StackOverflow) \
|
macro(StackOverflow) \
|
||||||
|
|
@ -291,7 +302,8 @@ struct ErrorODRViolation : ErrorBase {
|
||||||
macro(StringFunctionMemoryRangesOverlap) \
|
macro(StringFunctionMemoryRangesOverlap) \
|
||||||
macro(StringFunctionSizeOverflow) \
|
macro(StringFunctionSizeOverflow) \
|
||||||
macro(BadParamsToAnnotateContiguousContainer) \
|
macro(BadParamsToAnnotateContiguousContainer) \
|
||||||
macro(ODRViolation)
|
macro(ODRViolation) \
|
||||||
|
macro(InvalidPointerPair)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
#define ASAN_DEFINE_ERROR_KIND(name) kErrorKind##name,
|
#define ASAN_DEFINE_ERROR_KIND(name) kErrorKind##name,
|
||||||
|
|
|
||||||
|
|
@ -414,19 +414,11 @@ void ReportODRViolation(const __asan_global *g1, u32 stack_id1,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------- CheckForInvalidPointerPair ----------- {{{1
|
// ----------------------- CheckForInvalidPointerPair ----------- {{{1
|
||||||
static NOINLINE void
|
static NOINLINE void ReportInvalidPointerPair(uptr pc, uptr bp, uptr sp,
|
||||||
ReportInvalidPointerPair(uptr pc, uptr bp, uptr sp, uptr a1, uptr a2) {
|
uptr a1, uptr a2) {
|
||||||
ScopedInErrorReport in_report;
|
ScopedInErrorReport in_report;
|
||||||
const char *bug_type = "invalid-pointer-pair";
|
ErrorInvalidPointerPair error(GetCurrentTidOrInvalid(), pc, bp, sp, a1, a2);
|
||||||
Decorator d;
|
in_report.ReportError(error);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE void CheckForInvalidPointerPair(void *p1, void *p2) {
|
static INLINE void CheckForInvalidPointerPair(void *p1, void *p2) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue