[PATCH] D13452: [asan] On OS X, log reports to syslog and os_trace (version 2)

Anna Zaks via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 5 14:49:20 PDT 2015


zaks.anna created this revision.
zaks.anna added reviewers: glider, samsonov, kcc.
zaks.anna added subscribers: filcab, kubabrecka, llvm-commits, eugenis.
Herald added subscribers: srhines, danalbert, tberghammer.

When ASan currently detects a bug, by default it will only print out the text of the report to stderr.  This patch changes this behavior and writes the full text of the report to syslog before we terminate the process.  It also calls `os_trace` (Activity Tracing available on OS X and iOS) with a message saying that the report is available in syslog.  This is useful, because this message will be shown in the crash log.

For this to work, the patch makes sure we store the full report into `error_message_buffer` unconditionally, and it also strips out ANSI escape sequences from the report (they are used when producing colored reports).

This is the second version of the patch that addresses several concerns raised in http://reviews.llvm.org/D11981
 - Added a unit test for removal of color sequences
 - Moved the logic to sanitizer_common, instead of ASan so that all other tools could use error report logging. (Note, that this introduced some ugliness due to the specifics of os_trace, which only allows us to log literal strings and I think it's important to log the name of the tool that produced the report there.)
 - Refactored the Android specific WriteToSyslog logic to make it reusable by other platforms.
 - Added a lock to AppendToErrorMessageBuffer.
 - Made sure the logging is off for testing. The code will get executed by abort_on_error.cc test that runs with the default options.

I've initially tried to log to syslog during printing, which is done on Android right now. The advantage is that if we crash during error reporting or the produced error does not go through ScopedInErrorReport, we would still get a (partial) message in the syslog. However, that solution is very problematic on OS X. One issue is that the logging routine uses GCD, which may spawn a new thread on its behalf. In many cases, the reporting logic locks threadRegistry, which leads to deadlocks. 

http://reviews.llvm.org/D13452

Files:
  lib/asan/asan_report.cc
  lib/asan/tests/asan_test_main.cc
  lib/sanitizer_common/sanitizer_common.cc
  lib/sanitizer_common/sanitizer_common.h
  lib/sanitizer_common/sanitizer_common_libcdep.cc
  lib/sanitizer_common/sanitizer_flags.inc
  lib/sanitizer_common/sanitizer_linux_libcdep.cc
  lib/sanitizer_common/sanitizer_mac.cc
  lib/sanitizer_common/sanitizer_printf.cc
  lib/sanitizer_common/tests/sanitizer_common_test.cc
  test/asan/lit.cfg
  test/ubsan/lit.common.cfg

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13452.36555.patch
Type: text/x-patch
Size: 14366 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151005/18300610/attachment.bin>


More information about the llvm-commits mailing list