[ubsan] Fix print_stacktrace=1:fast_unwind_on_fatal=0 to correctly fallback to fast...
authorFangrui Song <i@maskray.me>
Tue, 12 Apr 2022 18:24:19 +0000 (11:24 -0700)
committerFangrui Song <i@maskray.me>
Tue, 12 Apr 2022 18:24:19 +0000 (11:24 -0700)
commitfdd424e37abf3fa411c07f1e08fee72cfe7bb25b
tree94888e67bac005a7d349011b028aed95d5872f9f
parentdeadda749aef22dba4727f5c4d76090ecca559ac
[ubsan] Fix print_stacktrace=1:fast_unwind_on_fatal=0 to correctly fallback to fast unwinder

ubsan_GetStackTrace (from 52b751088b11547e0f4ef0589ebbe5e57752c68c) called by
~ScopeReport leaves top/bottom zeroes in the
`!WillUseFastUnwind(request_fast_unwind)` code path.
When BufferedStackTrace::Unwind falls back to UnwindFast,
`if (stack_top < 4096) return;` will return early, leaving just one frame in the stack trace.

Fix this by always initializing top/bottom like 261d6e05d5574bec753ea6b7e9a7f99229927753.

Reviewed By: eugenis, yln

Differential Revision: https://reviews.llvm.org/D123562
compiler-rt/lib/ubsan/ubsan_diag.cpp
compiler-rt/test/ubsan/TestCases/Misc/Linux/diag-stacktrace.cpp [new file with mode: 0644]