[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
This commit is contained in:
Florian Mayer 2021-06-18 12:55:40 +01:00
parent 88d93923e6
commit e0b68f7149
2 changed files with 10 additions and 2 deletions

View 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()) {

View 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
}