[compiler-rt] 15754ac - [scudo][standalone] Split logs on Android
Kostya Kortchinsky via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 11:30:19 PDT 2020
Author: Kostya Kortchinsky
Date: 2020-04-14T11:29:57-07:00
New Revision: 15754acc5985188509f5eefaefa308393759b822
URL: https://github.com/llvm/llvm-project/commit/15754acc5985188509f5eefaefa308393759b822
DIFF: https://github.com/llvm/llvm-project/commit/15754acc5985188509f5eefaefa308393759b822.diff
LOG: [scudo][standalone] Split logs on Android
Summary:
The function used to log on Android will cut the message past
a certain amount of characters, which mostly materializes when
dumping the size class map on OOM.
This change splits the log message at newline boundaries.
Reviewers: pcc, cferris, hctim, eugenis
Subscribers: #sanitizers, llvm-commits
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D78018
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 040e1f039efa..0ab96836fc44 100644
--- a/compiler-rt/lib/scudo/standalone/linux.cpp
+++ b/compiler-rt/lib/scudo/standalone/linux.cpp
@@ -171,6 +171,23 @@ extern "C" WEAK int async_safe_write_log(int pri, const char *tag,
void outputRaw(const char *Buffer) {
if (&async_safe_write_log) {
constexpr s32 AndroidLogInfo = 4;
+ constexpr uptr MaxLength = 1024U;
+ char LocalBuffer[MaxLength];
+ while (strlen(Buffer) > MaxLength) {
+ uptr P;
+ for (P = MaxLength - 1; P > 0; P--) {
+ if (Buffer[P] == '\n') {
+ memcpy(LocalBuffer, Buffer, P);
+ LocalBuffer[P] = '\0';
+ async_safe_write_log(AndroidLogInfo, "scudo", LocalBuffer);
+ Buffer = &Buffer[P + 1];
+ break;
+ }
+ }
+ // If no newline was found, just log the buffer.
+ if (P == 0)
+ break;
+ }
async_safe_write_log(AndroidLogInfo, "scudo", Buffer);
} else {
write(2, Buffer, strlen(Buffer));
More information about the llvm-commits
mailing list