summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_common_libcdep.cc
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2015-11-20 18:42:01 +0000
committerAnna Zaks <ganna@apple.com>2015-11-20 18:42:01 +0000
commitdc4a93dca06f8f55c14d9d97ab29b54520e5419c (patch)
tree9f1cd41bfe9d047e0cc4da75e0f2ae1027dca280 /lib/sanitizer_common/sanitizer_common_libcdep.cc
parent60e25ccedab89f75b0d6a5373f6a7a544f8aa6fe (diff)
[asan] Fix the deadlocks introduced by "On OS X, log reports to syslog and os_trace" commit
[asan] On OS X, log reports to syslog and os_trace, has been reverted in r252076 due to deadlocks on earlier versions of OS X. Alexey has also noticed deadlocks in some corner cases on Linux. This patch, if applied on top of the logging patch (http://reviews.llvm.org/D13452), addresses the known deadlock issues. (This also proactively removes the color escape sequences from the error report buffer since we have to copy the buffer anyway.) Differential Revision: http://reviews.llvm.org/D14470 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253689 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_common_libcdep.cc')
-rw-r--r--lib/sanitizer_common/sanitizer_common_libcdep.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/sanitizer_common/sanitizer_common_libcdep.cc b/lib/sanitizer_common/sanitizer_common_libcdep.cc
index 9095002aa..b5d46f244 100644
--- a/lib/sanitizer_common/sanitizer_common_libcdep.cc
+++ b/lib/sanitizer_common/sanitizer_common_libcdep.cc
@@ -12,7 +12,7 @@
//===----------------------------------------------------------------------===//
#include "sanitizer_common.h"
-#include "sanitizer_allocator_internal.h"
+
#include "sanitizer_flags.h"
#include "sanitizer_stackdepot.h"
#include "sanitizer_stacktrace.h"
@@ -119,13 +119,14 @@ void BackgroundThread(void *arg) {
}
}
-void WriteToSyslog(const char *buffer) {
- char *copy = internal_strdup(buffer);
- char *p = copy;
+void WriteToSyslog(const char *msg) {
+ InternalScopedString msg_copy(kErrorMessageBufferSize);
+ msg_copy.append("%s", msg);
+ char *p = msg_copy.data();
char *q;
// Remove color sequences since syslogs cannot print them.
- RemoveANSIEscapeSequencesFromString(copy);
+ RemoveANSIEscapeSequencesFromString(p);
// Print one line at a time.
// syslog, at least on Android, has an implicit message length limit.
@@ -137,7 +138,6 @@ void WriteToSyslog(const char *buffer) {
if (q)
p = q + 1;
} while (q);
- InternalFree(copy);
}
void MaybeStartBackgroudThread() {