From f529a9f324a8eb4a0f2c5e662b6c57a6a775d62f Mon Sep 17 00:00:00 2001 From: Mitch Phillips <31459023+hctim@users.noreply.github.com> Date: Mon, 12 Dec 2022 13:53:08 -0800 Subject: [PATCH] [GWP-ASan] Fix sanitizer backtrace util using wrong print. The sanitizer backtrace is used in tests, and calling StackTrace.Print() means that it uses the sanitizer's Printf(), rather than GWP-ASan's Printf(). In the current code, GWP-ASan's Printf() *is* the sanitizer print, but this isn't guaranteed to be the case, and will change in an upcoming patch. Reviewed By: eugenis Differential Revision: https://reviews.llvm.org/D139748 --- compiler-rt/lib/gwp_asan/optional/backtrace_sanitizer_common.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/gwp_asan/optional/backtrace_sanitizer_common.cpp b/compiler-rt/lib/gwp_asan/optional/backtrace_sanitizer_common.cpp index e6cce86..f8b9cbd 100644 --- a/compiler-rt/lib/gwp_asan/optional/backtrace_sanitizer_common.cpp +++ b/compiler-rt/lib/gwp_asan/optional/backtrace_sanitizer_common.cpp @@ -72,7 +72,9 @@ static void PrintBacktrace(uintptr_t *Trace, size_t TraceLength, return; } - StackTrace.Print(); + __sanitizer::InternalScopedString buffer; + StackTrace.PrintTo(&buffer); + Printf("%s\n", buffer.data()); } } // anonymous namespace -- 2.7.4