[compiler-rt] r246831 - [asan] Delay syslog use on Android until the end of __asan_init.

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 3 18:15:26 PDT 2015


Author: eugenis
Date: Thu Sep  3 20:15:25 2015
New Revision: 246831

URL: http://llvm.org/viewvc/llvm-project?rev=246831&view=rev
Log:
[asan] Delay syslog use on Android until the end of __asan_init.

Due to a slightly different initialization order, syslog on
android/x86 calls vsnprintf, which can not be handled until interceptors
are initialized at least.

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc?rev=246831&r1=246830&r2=246831&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux_libcdep.cc Thu Sep  3 20:15:25 2015
@@ -538,7 +538,8 @@ uptr GetRSS() {
 // Starting with the L release, syslog() works and is preferable to
 // __android_log_write.
 #if SANITIZER_LINUX
-#if SANITIZER_ANDROID && __ANDROID_API__ < 21
+
+#if SANITIZER_ANDROID
 static atomic_uint8_t android_log_initialized;
 
 void AndroidLogInit() {
@@ -548,17 +549,19 @@ void AndroidLogInit() {
 static bool IsSyslogAvailable() {
   return atomic_load(&android_log_initialized, memory_order_acquire);
 }
-
-static void WriteOneLineToSyslog(const char *s) {
-  __android_log_write(ANDROID_LOG_INFO, NULL, s);
-}
 #else
 void AndroidLogInit() {}
 
 static bool IsSyslogAvailable() { return true; }
+#endif  // SANITIZER_ANDROID
 
-static void WriteOneLineToSyslog(const char *s) { syslog(LOG_INFO, "%s", s); }
+static void WriteOneLineToSyslog(const char *s) {
+#if SANITIZER_ANDROID &&__ANDROID_API__ < 21
+  __android_log_write(ANDROID_LOG_INFO, NULL, s);
+#else
+  syslog(LOG_INFO, "%s", s);
 #endif
+}
 
 void WriteToSyslog(const char *buffer) {
   if (!IsSyslogAvailable())




More information about the llvm-commits mailing list