From: Florian Mayer Date: Fri, 18 Jun 2021 11:55:40 +0000 (+0100) Subject: [hwasan] Clarify report for allocation-tail-overwritten. X-Git-Tag: llvmorg-14-init~3602 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e0b68f7149f9c66ba9e81878729225421f99a030;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/compiler-rt/lib/hwasan/hwasan_report.cpp b/compiler-rt/lib/hwasan/hwasan_report.cpp index 7b2a85b..b39dade 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 acce591..fcbc8f1 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 }