[PATCH] D24394: [asan] Reify ErrorStringFunctionSizeOverflow
Filipe Cabecinhas via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 9 06:37:49 PDT 2016
filcab created this revision.
filcab added reviewers: kcc, eugenis, vitalybuka.
filcab added a subscriber: llvm-commits.
Herald added a subscriber: kubabrecka.
Continuing implementation mentioned in this thread: http://lists.llvm.org/pipermail/llvm-dev/2016-July/101933.html
https://reviews.llvm.org/D24394
Files:
lib/asan/asan_errors.cc
lib/asan/asan_errors.h
lib/asan/asan_report.cc
Index: lib/asan/asan_report.cc
===================================================================
--- lib/asan/asan_report.cc
+++ lib/asan/asan_report.cc
@@ -391,15 +391,9 @@
void ReportStringFunctionSizeOverflow(uptr offset, uptr size,
BufferedStackTrace *stack) {
ScopedInErrorReport in_report;
- Decorator d;
- const char *bug_type = "negative-size-param";
- Printf("%s", d.Warning());
- Report("ERROR: AddressSanitizer: %s: (size=%zd)\n", bug_type, size);
- Printf("%s", d.EndWarning());
- ScarinessScore::PrintSimple(10, bug_type);
- stack->Print();
- PrintAddressDescription(offset, size, bug_type);
- ReportErrorSummary(bug_type, stack);
+ ErrorStringFunctionSizeOverflow error(GetCurrentTidOrInvalid(), stack, offset,
+ size);
+ in_report.ReportError(error);
}
void ReportBadParamsToAnnotateContiguousContainer(uptr beg, uptr end,
Index: lib/asan/asan_errors.h
===================================================================
--- lib/asan/asan_errors.h
+++ lib/asan/asan_errors.h
@@ -229,6 +229,25 @@
void Print();
};
+struct ErrorStringFunctionSizeOverflow : ErrorBase {
+ u32 tid;
+ // ErrorStringFunctionSizeOverflow doesn't own the stack trace.
+ BufferedStackTrace *stack;
+ AddressDescriptionBase addr_description;
+ uptr size;
+ // VS2013 doesn't implement unrestricted unions, so we need a trivial default
+ // constructor
+ ErrorStringFunctionSizeOverflow() = default;
+ ErrorStringFunctionSizeOverflow(u32 tid_, BufferedStackTrace *stack_,
+ uptr addr, uptr size_)
+ : tid(tid_), stack(stack_), size(size_) {
+ scariness.Clear();
+ scariness.Scare(10, "negative-size-param");
+ addr_description = AddressDescription(addr);
+ }
+ void Print();
+};
+
#define FOR_EACH_ERROR_KIND_MEMBER_NAME_PAIR(macro) \
macro(StackOverflow, stack_overflow) \
macro(DeadlySignal, deadly_signal) \
@@ -240,7 +259,8 @@
macro(SanitizerGetAllocatedSizeNotOwned, \
sanitizer_get_allocated_size_not_owned) \
macro(StringFunctionMemoryRangesOverlap, \
- string_function_memory_ranges_overlap)
+ string_function_memory_ranges_overlap) \
+ macro(StringFunctionSizeOverflow, string_function_size_overflow)
enum ErrorKind {
kErrorKindInvalid = 0,
Index: lib/asan/asan_errors.cc
===================================================================
--- lib/asan/asan_errors.cc
+++ lib/asan/asan_errors.cc
@@ -209,4 +209,16 @@
ReportErrorSummary(bug_type, stack);
}
+void ErrorStringFunctionSizeOverflow::Print() {
+ Decorator d;
+ Printf("%s", d.Warning());
+ const char *bug_type = "negative-size-param";
+ Report("ERROR: AddressSanitizer: %s: (size=%zd)\n", bug_type, size);
+ Printf("%s", d.EndWarning());
+ scariness.Print();
+ stack->Print();
+ addr_description.Print();
+ ReportErrorSummary(bug_type, stack);
+}
+
} // namespace __asan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24394.70828.patch
Type: text/x-patch
Size: 3093 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160909/5c909158/attachment.bin>
More information about the llvm-commits
mailing list