[PATCH] [ASan] Do not rely on malloc context in allocator reports

Yury Gribov tetra2005 at gmail.com
Tue Nov 12 03:33:08 PST 2013



================
Comment at: lib/asan/asan_report.h:42
@@ -41,3 +41,3 @@
 void NORETURN ReportMallocUsableSizeNotOwned(uptr addr,
-                                             StackTrace *stack);
+                                             StackTrace *free_stack);
 void NORETURN ReportAsanGetAllocatedSizeNotOwned(uptr addr,
----------------
Alexey Samsonov wrote:
> It's not a free_stack, it's a call stack of malloc_usable_size.
> Moreover, looks like with this change, asan_malloc_usable_size doesn't need to take unwinded stack trace as its argument, only a pc/bp to  optionally unwind stack on failure if ReportMallocUsableSizeNotOwned is called.
Ok.

================
Comment at: lib/asan/asan_report.h:44
@@ -43,3 +43,3 @@
 void NORETURN ReportAsanGetAllocatedSizeNotOwned(uptr addr,
-                                                 StackTrace *stack);
+                                                 StackTrace *free_stack);
 void NORETURN ReportStringFunctionMemoryRangesOverlap(
----------------
Alexey Samsonov wrote:
> It's not a free_stack, it's a call stack of __asan_get_allocated_size(). And it's already unwinded using GET_STACK_TRACE_FATAL_HERE, so you don't really need to modify this function.
Ok.

================
Comment at: lib/asan/lit_tests/TestCases/Linux/malloc_delete_mismatch.cc:1
@@ -1,2 +1,2 @@
 // Check that we detect malloc/delete mismatch only if the approptiate flag
 // is set.
----------------
Alexey Samsonov wrote:
> I'd also appreciate at least one cross-platform test case (i.e. not Linux-only).
Ok, will take some time to setup VS here.

================
Comment at: lib/sanitizer_common/sanitizer_stacktrace_libcdep.cc:20
@@ -19,1 +19,3 @@
                         uptr stack_bottom, bool request_fast_unwind) {
+  top_frame_bp = bp;
+
----------------
Alexey Samsonov wrote:
> You may assign this only if size of unwinded stack is greater than zero.
I'll replace with `top_frame_bp = size ? bp : 0;'.


http://llvm-reviews.chandlerc.com/D2136



More information about the llvm-commits mailing list