[compiler-rt] a1f6ff2 - [scudo][standalone] Fix Android logging
Kostya Kortchinsky via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 28 11:03:56 PST 2020
Author: Kostya Kortchinsky
Date: 2020-01-28T11:03:39-08:00
New Revision: a1f6ff26814b86fdd7dfc9083bbefe5cf1790ab8
URL: https://github.com/llvm/llvm-project/commit/a1f6ff26814b86fdd7dfc9083bbefe5cf1790ab8
DIFF: https://github.com/llvm/llvm-project/commit/a1f6ff26814b86fdd7dfc9083bbefe5cf1790ab8.diff
LOG: [scudo][standalone] Fix Android logging
Summary:
Zygote & children's stderr is lost, so use Bionic's provided allocation
free syslog function for `outputRaw`. Get rid of the mutex as it's not
vital and could cause issues with `fork`.
Reviewers: cferris, pcc, eugenis, hctim, morehouse
Subscribers: #sanitizers, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D73561
Added:
Modified:
compiler-rt/lib/scudo/standalone/linux.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/scudo/standalone/linux.cpp b/compiler-rt/lib/scudo/standalone/linux.cpp
index 3b7562844d72..040e1f039efa 100644
--- a/compiler-rt/lib/scudo/standalone/linux.cpp
+++ b/compiler-rt/lib/scudo/standalone/linux.cpp
@@ -164,10 +164,17 @@ bool getRandom(void *Buffer, uptr Length, UNUSED bool Blocking) {
return (ReadBytes == static_cast<ssize_t>(Length));
}
+// Allocation free syslog-like API.
+extern "C" WEAK int async_safe_write_log(int pri, const char *tag,
+ const char *msg);
+
void outputRaw(const char *Buffer) {
- static HybridMutex Mutex;
- ScopedLock L(Mutex);
- write(2, Buffer, strlen(Buffer));
+ if (&async_safe_write_log) {
+ constexpr s32 AndroidLogInfo = 4;
+ async_safe_write_log(AndroidLogInfo, "scudo", Buffer);
+ } else {
+ write(2, Buffer, strlen(Buffer));
+ }
}
extern "C" WEAK void android_set_abort_message(const char *);
More information about the llvm-commits
mailing list