[compiler-rt] e0b68f7 - [hwasan] Clarify report for allocation-tail-overwritten.

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 18 10:52:53 PDT 2021


Author: Florian Mayer
Date: 2021-06-18T18:52:41+01:00
New Revision: e0b68f7149f9c66ba9e81878729225421f99a030

URL: https://github.com/llvm/llvm-project/commit/e0b68f7149f9c66ba9e81878729225421f99a030
DIFF: https://github.com/llvm/llvm-project/commit/e0b68f7149f9c66ba9e81878729225421f99a030.diff

LOG: [hwasan] Clarify report for allocation-tail-overwritten.

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/hwasan/hwasan_report.cpp b/compiler-rt/lib/hwasan/hwasan_report.cpp
index 7b2a85b4f6bc1..b39dade11347a 100644
--- a/compiler-rt/lib/hwasan/hwasan_report.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_report.cpp
@@ -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()) {

diff  --git a/compiler-rt/test/hwasan/TestCases/tail-magic.c b/compiler-rt/test/hwasan/TestCases/tail-magic.c
index acce591a7ac99..fcbc8f115d73c 100644
--- a/compiler-rt/test/hwasan/TestCases/tail-magic.c
+++ b/compiler-rt/test/hwasan/TestCases/tail-magic.c
@@ -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
 }


        


More information about the llvm-commits mailing list