[compiler-rt] r180784 - asan/tsan: fix printf(), on the second pass it prints garbage and crashes on random pointer dereference
Dmitry Vyukov
dvyukov at google.com
Tue Apr 30 05:27:48 PDT 2013
Author: dvyukov
Date: Tue Apr 30 07:27:48 2013
New Revision: 180784
URL: http://llvm.org/viewvc/llvm-project?rev=180784&view=rev
Log:
asan/tsan: fix printf(), on the second pass it prints garbage and crashes on random pointer dereference
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc?rev=180784&r1=180783&r2=180784&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_printf.cc Tue Apr 30 07:27:48 2013
@@ -192,6 +192,8 @@ static void CallPrintfAndReportCallback(
static void SharedPrintfCode(bool append_pid, const char *format,
va_list args) {
+ va_list args2;
+ va_copy(args2, args);
const int kLen = 16 * 1024;
// |local_buffer| is small enough not to overflow the stack and/or violate
// the stack limit enforced by TSan (-Wframe-larger-than=512). On the other
@@ -205,6 +207,8 @@ static void SharedPrintfCode(bool append
// mmaped buffer.
for (int use_mmap = 0; use_mmap < 2; use_mmap++) {
if (use_mmap) {
+ va_end(args);
+ va_copy(args, args2);
buffer = (char*)MmapOrDie(kLen, "Report");
buffer_size = kLen;
}
@@ -235,6 +239,7 @@ static void SharedPrintfCode(bool append
// If we had mapped any memory, clean up.
if (buffer != local_buffer)
UnmapOrDie((void *)buffer, buffer_size);
+ va_end(args2);
}
void Printf(const char *format, ...) {
More information about the llvm-commits
mailing list