[PATCH] D39753: [scudo] Support syslog logging on Android and in dieWithMessage

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 7 11:53:08 PST 2017


cryptoad created this revision.
Herald added a subscriber: srhines.

This is controlled by the common option `log_to_syslog`, which is enabled by
default on Android.

There is a side effect to this as `syslog` can use `malloc` or the like. This
is not ideal as this could be called in a failure path while the heap is
corrupted, but it's pretty much compulsory to have that for Android.

The plan is to change `WriteOneLineToSyslog` to use `async_safe_write_log` if
available, which doesn't do dynamic memory allocation (added to the Bionic libc
somewhat recently).


https://reviews.llvm.org/D39753

Files:
  lib/scudo/scudo_allocator.cpp
  lib/scudo/scudo_utils.cpp


Index: lib/scudo/scudo_utils.cpp
===================================================================
--- lib/scudo/scudo_utils.cpp
+++ lib/scudo/scudo_utils.cpp
@@ -77,6 +77,7 @@
   __sanitizer::VSNPrintf(Message, sizeof(Message), Format, Args);
   va_end(Args);
   RawWrite(Message);
+  LogMessageOnPrintf(Message);
   Die();
 }
 
Index: lib/scudo/scudo_allocator.cpp
===================================================================
--- lib/scudo/scudo_allocator.cpp
+++ lib/scudo/scudo_allocator.cpp
@@ -195,18 +195,19 @@
   CHECK(!ScudoInitIsRunning && "Scudo init calls itself!");
   ScudoInitIsRunning = true;
 
+  CacheBinaryName();
+
   // Check if hardware CRC32 is supported in the binary and by the platform, if
   // so, opt for the CRC32 hardware version of the checksum.
   if (computeHardwareCRC32 && testCPUFeature(CRC32CPUFeature))
     atomic_store_relaxed(&HashAlgorithm, CRC32Hardware);
 
   initFlags();
-
   AllocatorOptions Options;
   Options.setFrom(getFlags(), common_flags());
   initScudoInternal(Options);
 
-  // TODO(kostyak): determine if MaybeStartBackgroudThread could be of some use.
+  AndroidLogInit();
 
   ScudoInitIsRunning = false;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39753.121951.patch
Type: text/x-patch
Size: 1178 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171107/2381e23c/attachment.bin>


More information about the llvm-commits mailing list