[GWP-ASan] Fix sanitizer backtrace util using wrong print.
authorMitch Phillips <31459023+hctim@users.noreply.github.com>
Mon, 12 Dec 2022 21:53:08 +0000 (13:53 -0800)
committerMitch Phillips <31459023+hctim@users.noreply.github.com>
Mon, 12 Dec 2022 21:53:11 +0000 (13:53 -0800)
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

index e6cce86..f8b9cbd 100644 (file)
@@ -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