Skip to content

Commit a1f6ff2

Browse files
author
Kostya Kortchinsky
committed
[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
1 parent b8461fc commit a1f6ff2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

compiler-rt/lib/scudo/standalone/linux.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,17 @@ bool getRandom(void *Buffer, uptr Length, UNUSED bool Blocking) {
164164
return (ReadBytes == static_cast<ssize_t>(Length));
165165
}
166166

167+
// Allocation free syslog-like API.
168+
extern "C" WEAK int async_safe_write_log(int pri, const char *tag,
169+
const char *msg);
170+
167171
void outputRaw(const char *Buffer) {
168-
static HybridMutex Mutex;
169-
ScopedLock L(Mutex);
170-
write(2, Buffer, strlen(Buffer));
172+
if (&async_safe_write_log) {
173+
constexpr s32 AndroidLogInfo = 4;
174+
async_safe_write_log(AndroidLogInfo, "scudo", Buffer);
175+
} else {
176+
write(2, Buffer, strlen(Buffer));
177+
}
171178
}
172179

173180
extern "C" WEAK void android_set_abort_message(const char *);

0 commit comments

Comments
 (0)