Skip to content

Commit

Permalink
Fix unsymbolized stack history printing.
Browse files Browse the repository at this point in the history
Summary:
When symbols are unavailable, the current code prints
  sp: ... pc: ... (null) (null)
instead of module name + offset.

Change the output to include module name and offset, and also to match
the regular sanitizer stack trace format so that it is recognized by
symbolize.py out of the box.

Reviewers: kcc, pcc

Subscribers: kubamracek, jdoerfert, llvm-commits

Tags: #llvm

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

llvm-svn: 354157
  • Loading branch information
eugenis committed Feb 15, 2019
1 parent a70d88c commit 360163f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler-rt/lib/hwasan/hwasan_report.cc
Expand Up @@ -252,8 +252,8 @@ void PrintAddressDescription(
uptr pc_mask = (1ULL << 48) - 1;
uptr pc = record & pc_mask;
if (SymbolizedStack *frame = Symbolizer::GetOrInit()->SymbolizePC(pc)) {
frame_desc.append(" sp: 0x%zx pc: %p ", sp, pc);
RenderFrame(&frame_desc, "in %f %s:%l\n", 0, frame->info,
frame_desc.append(" sp: 0x%zx ", sp);
RenderFrame(&frame_desc, "#%n %p %F %L\n", 0, frame->info,
common_flags()->symbolize_vs_style,
common_flags()->strip_path_prefix);
frame->ClearAll();
Expand Down
5 changes: 5 additions & 0 deletions compiler-rt/test/hwasan/TestCases/stack-uar.c
@@ -1,5 +1,6 @@
// Tests use-after-return detection and reporting.
// RUN: %clang_hwasan -O0 -fno-discard-value-names %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clang_hwasan -O0 -fno-discard-value-names %s -o %t && not %env_hwasan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOSYM

// REQUIRES: stable-runtime

Expand Down Expand Up @@ -37,5 +38,9 @@ int main() {
// CHECK: buggy
// CHECK: 4096 zzz

// NOSYM: Previously allocated frames:
// NOSYM-NEXT: sp: 0x{{.*}} #0 0x{{.*}} ({{.*}}/stack-uar.c.tmp+0x{{.*}}){{$}}
// NOSYM-NEXT: 16 CCC;

// CHECK: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in main
}

0 comments on commit 360163f

Please sign in to comment.