[PATCH] D73561: [scudo][standalone] Fix Android logging

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 28 09:40:56 PST 2020


cryptoad created this revision.
cryptoad added reviewers: cferris, pcc, eugenis, hctim, morehouse.
Herald added projects: Sanitizers, LLVM.
Herald added a subscriber: Sanitizers.

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`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73561

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


Index: compiler-rt/lib/scudo/standalone/linux.cpp
===================================================================
--- compiler-rt/lib/scudo/standalone/linux.cpp
+++ compiler-rt/lib/scudo/standalone/linux.cpp
@@ -164,10 +164,17 @@
   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) {
+    const 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 *);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73561.240912.patch
Type: text/x-patch
Size: 840 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200128/817ffb84/attachment.bin>


More information about the llvm-commits mailing list