[PATCH] D24392: [asan] Reify ErrorSanitizerGetAllocatedSizeNotOwned
Filipe Cabecinhas via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 9 06:36:52 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/D24392
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
@@ -372,15 +372,9 @@
void ReportSanitizerGetAllocatedSizeNotOwned(uptr addr,
BufferedStackTrace *stack) {
ScopedInErrorReport in_report;
- Decorator d;
- Printf("%s", d.Warning());
- Report("ERROR: AddressSanitizer: attempting to call "
- "__sanitizer_get_allocated_size() for pointer which is "
- "not owned: %p\n", addr);
- Printf("%s", d.EndWarning());
- stack->Print();
- DescribeAddressIfHeap(addr);
- ReportErrorSummary("bad-__sanitizer_get_allocated_size", stack);
+ ErrorSanitizerGetAllocatedSizeNotOwned error(addr, GetCurrentTidOrInvalid(),
+ stack);
+ in_report.ReportError(error);
}
void ReportStringFunctionMemoryRangesOverlap(const char *function,
Index: lib/asan/asan_errors.h
===================================================================
--- lib/asan/asan_errors.h
+++ lib/asan/asan_errors.h
@@ -180,14 +180,34 @@
void Print();
};
-#define FOR_EACH_ERROR_KIND_MEMBER_NAME_PAIR(macro) \
- macro(StackOverflow, stack_overflow) \
- macro(DeadlySignal, deadly_signal) \
- macro(DoubleFree, double_free) \
- macro(NewDeleteSizeMismatch, new_delete_size_mismatch) \
- macro(FreeNotMalloced, free_not_malloced) \
- macro(AllocTypeMismatch, alloc_type_mismatch) \
- macro(MallocUsableSizeNotOwned, malloc_uzable_size_not_owned)
+struct ErrorSanitizerGetAllocatedSizeNotOwned : ErrorBase {
+ u32 tid;
+ // ErrorSanitizerGetAllocatedSizeNotOwned doesn't own the stack trace.
+ BufferedStackTrace *stack;
+ AddressDescriptionBase addr_description;
+ // VS2013 doesn't implement unrestricted unions, so we need a trivial default
+ // constructor
+ ErrorSanitizerGetAllocatedSizeNotOwned() = default;
+ ErrorSanitizerGetAllocatedSizeNotOwned(uptr addr, u32 tid_,
+ BufferedStackTrace *stack_)
+ : tid(tid_), stack(stack_) {
+ addr_description =
+ AddressDescription(addr, /*shouldLockThreadRegistry=*/false);
+ scariness.Clear();
+ }
+ void Print();
+};
+
+#define FOR_EACH_ERROR_KIND_MEMBER_NAME_PAIR(macro) \
+ macro(StackOverflow, stack_overflow) \
+ macro(DeadlySignal, deadly_signal) \
+ macro(DoubleFree, double_free) \
+ macro(NewDeleteSizeMismatch, new_delete_size_mismatch) \
+ macro(FreeNotMalloced, free_not_malloced) \
+ macro(AllocTypeMismatch, alloc_type_mismatch) \
+ macro(MallocUsableSizeNotOwned, malloc_usable_size_not_owned) \
+ macro(SanitizerGetAllocatedSizeNotOwned, \
+ sanitizer_get_allocated_size_not_owned)
enum ErrorKind {
kErrorKindInvalid = 0,
Index: lib/asan/asan_errors.cc
===================================================================
--- lib/asan/asan_errors.cc
+++ lib/asan/asan_errors.cc
@@ -177,4 +177,17 @@
ReportErrorSummary("bad-malloc_usable_size", stack);
}
+void ErrorSanitizerGetAllocatedSizeNotOwned::Print() {
+ Decorator d;
+ Printf("%s", d.Warning());
+ Report(
+ "ERROR: AddressSanitizer: attempting to call "
+ "__sanitizer_get_allocated_size() for pointer which is not owned: %p\n",
+ addr_description.Address());
+ Printf("%s", d.EndWarning());
+ stack->Print();
+ addr_description.Print();
+ ReportErrorSummary("bad-__sanitizer_get_allocated_size", stack);
+}
+
} // namespace __asan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24392.70826.patch
Type: text/x-patch
Size: 3719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160909/2e7b39ea/attachment.bin>
More information about the llvm-commits
mailing list