[PATCH] D24392: [asan] Reify ErrorSanitizerGetAllocatedSizeNotOwned
Filipe Cabecinhas via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 13 13:56:19 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL281392: [asan] Reify ErrorSanitizerGetAllocatedSizeNotOwned (authored by filcab).
Changed prior to commit:
https://reviews.llvm.org/D24392?vs=71170&id=71235#toc
Repository:
rL LLVM
https://reviews.llvm.org/D24392
Files:
compiler-rt/trunk/lib/asan/asan_errors.cc
compiler-rt/trunk/lib/asan/asan_errors.h
compiler-rt/trunk/lib/asan/asan_report.cc
Index: compiler-rt/trunk/lib/asan/asan_errors.h
===================================================================
--- compiler-rt/trunk/lib/asan/asan_errors.h
+++ compiler-rt/trunk/lib/asan/asan_errors.h
@@ -176,15 +176,33 @@
void Print();
};
+struct ErrorSanitizerGetAllocatedSizeNotOwned : ErrorBase {
+ // ErrorSanitizerGetAllocatedSizeNotOwned doesn't own the stack trace.
+ const BufferedStackTrace *stack;
+ AddressDescription addr_description;
+ // VS2013 doesn't implement unrestricted unions, so we need a trivial default
+ // constructor
+ ErrorSanitizerGetAllocatedSizeNotOwned() = default;
+ ErrorSanitizerGetAllocatedSizeNotOwned(u32 tid, BufferedStackTrace *stack_,
+ uptr addr)
+ : ErrorBase(tid),
+ stack(stack_),
+ addr_description(addr, /*shouldLockThreadRegistry=*/false) {
+ scariness.Clear();
+ }
+ void Print();
+};
+
// clang-format off
#define ASAN_FOR_EACH_ERROR_KIND(macro) \
macro(StackOverflow) \
macro(DeadlySignal) \
macro(DoubleFree) \
macro(NewDeleteSizeMismatch) \
macro(FreeNotMalloced) \
macro(AllocTypeMismatch) \
- macro(MallocUsableSizeNotOwned)
+ macro(MallocUsableSizeNotOwned) \
+ macro(SanitizerGetAllocatedSizeNotOwned)
// clang-format on
#define ASAN_DEFINE_ERROR_KIND(name) kErrorKind##name,
Index: compiler-rt/trunk/lib/asan/asan_errors.cc
===================================================================
--- compiler-rt/trunk/lib/asan/asan_errors.cc
+++ compiler-rt/trunk/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
Index: compiler-rt/trunk/lib/asan/asan_report.cc
===================================================================
--- compiler-rt/trunk/lib/asan/asan_report.cc
+++ compiler-rt/trunk/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(GetCurrentTidOrInvalid(), stack,
+ addr);
+ in_report.ReportError(error);
}
void ReportStringFunctionMemoryRangesOverlap(const char *function,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24392.71235.patch
Type: text/x-patch
Size: 3197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160913/fd202c6d/attachment.bin>
More information about the llvm-commits
mailing list