[hwasan] Clarify report for allocation-tail-overwritten.
authorFlorian Mayer <fmayer@google.com>
Fri, 18 Jun 2021 11:55:40 +0000 (12:55 +0100)
committerFlorian Mayer <fmayer@google.com>
Fri, 18 Jun 2021 17:52:41 +0000 (18:52 +0100)
Explain what the given stack trace means before showing it, rather than
only in the paragraph at the end.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D104523

compiler-rt/lib/hwasan/hwasan_report.cpp
compiler-rt/test/hwasan/TestCases/tail-magic.c

index 7b2a85b..b39dade 100644 (file)
@@ -547,6 +547,12 @@ void ReportTailOverwritten(StackTrace *stack, uptr tagged_addr, uptr orig_size,
   Report("ERROR: %s: %s; heap object [%p,%p) of size %zd\n", SanitizerToolName,
          bug_type, untagged_addr, untagged_addr + orig_size, orig_size);
   Printf("\n%s", d.Default());
+  Printf(
+      "Stack of invalid access unknown. Issue detected at deallocation "
+      "time.\n");
+  Printf("%s", d.Allocation());
+  Printf("deallocated here:\n");
+  Printf("%s", d.Default());
   stack->Print();
   HwasanChunkView chunk = FindHeapChunkByAddress(untagged_addr);
   if (chunk.Beg()) {
index acce591..fcbc8f1 100644 (file)
@@ -27,8 +27,10 @@ int main(int argc, char **argv) {
   overwrite_tail();
   free(p);
 // CHECK: ERROR: HWAddressSanitizer: allocation-tail-overwritten; heap object [{{.*}}) of size 20
-// CHECK: in main {{.*}}tail-magic.c:[[@LINE-2]]
+// CHECK: Stack of invalid access unknown. Issue detected at deallocation time.
+// CHECK: deallocated here:
+// CHECK: in main {{.*}}tail-magic.c:[[@LINE-4]]
 // CHECK: allocated here:
-// CHECK: in main {{.*}}tail-magic.c:[[@LINE-7]]
+// CHECK: in main {{.*}}tail-magic.c:[[@LINE-9]]
 // CHECK: Tail contains: .. .. .. .. 42 {{.. .. ..}} 66
 }