Index: lib/sanitizer_common/sanitizer_common_libcdep.cc =================================================================== --- lib/sanitizer_common/sanitizer_common_libcdep.cc +++ lib/sanitizer_common/sanitizer_common_libcdep.cc @@ -37,6 +37,10 @@ if (SANITIZER_WINDOWS) return false; + // The macOS syslog viewer doesn't know what to do with color codes. + if (common_flags()->log_to_syslog) + return false; + const char *flag = common_flags()->color; return internal_strcmp(flag, "always") == 0 || (internal_strcmp(flag, "auto") == 0 && report_file.SupportsColors()); Index: lib/ubsan/ubsan_diag.cc =================================================================== --- lib/ubsan/ubsan_diag.cc +++ lib/ubsan/ubsan_diag.cc @@ -100,8 +100,14 @@ const char *Note() const { return Black(); } const char *EndNote() const { return Default(); } }; + +void PrintToLog(const char *S) { + Printf("%s", S); + LogFullErrorReport(S); } +} // end anonymous namespace + SymbolizedStack *__ubsan::getSymbolizedLocation(uptr PC) { InitAsStandaloneIfNecessary(); return Symbolizer::GetOrInit()->SymbolizePC(PC); @@ -263,7 +269,7 @@ Max = addNoOverflow(Min, BytesToShow); if (!IsAccessibleMemoryRange(Min, Max - Min)) { - Printf("\n"); + PrintToLog("\n"); return; } @@ -319,7 +325,8 @@ Spaces += 2; } - Printf("%s", Buffer.data()); + PrintToLog(Buffer.data()); + // FIXME: Print names for anything we can identify within the line: // // * If we can identify the memory itself as belonging to a particular @@ -356,7 +363,7 @@ RenderText(&Buffer, Message, Args); Buffer.append("%s\n", Decor.Default()); - Printf("%s", Buffer.data()); + PrintToLog(Buffer.data()); if (Loc.isMemoryLocation()) PrintMemorySnippet(Decor, Loc.getMemoryLocation(), Ranges, NumRanges, Args); Index: test/ubsan/TestCases/Misc/log-path_test.cc =================================================================== --- test/ubsan/TestCases/Misc/log-path_test.cc +++ test/ubsan/TestCases/Misc/log-path_test.cc @@ -20,6 +20,10 @@ // RUN: %env_ubsan_opts=log_path='"%t.log"' %run %t 4 // RUN: not cat %t.log.* +// We should print out a report even if we're logging to syslog. +// RUN: %env_ubsan_opts=log_to_syslog=1 %run %t -4 2> %t.out +// RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.out + // FIXME: log_path is not supported on Windows yet. // XFAIL: win32