This is an archive of the discontinued LLVM Phabricator instance.

[sanitizers] Log all output to CrashReport on OS X
ClosedPublic

Authored by zaks.anna on Dec 9 2015, 2:53 PM.

Details

Summary

Log all of sanitizers' output (not just ASan bug reports) to CrashReport, which simplifies diagnosing failed checks as well as other errors. This also allows to strip the color sequences early from the printed buffer, which is more efficient than what we had perviously.

Diff Detail

Repository
rL LLVM

Event Timeline

zaks.anna updated this revision to Diff 42344.Dec 9 2015, 2:53 PM
zaks.anna retitled this revision from to [sanitizers] Log all output to CrashReport on OS X.
zaks.anna updated this object.
zaks.anna added reviewers: kubamracek, glider.
zaks.anna added a subscriber: llvm-commits.
kubamracek added inline comments.Dec 15 2015, 5:47 AM
lib/sanitizer_common/sanitizer_mac.h
49 ↗(On Diff #42344)

Don't we need a lock here? Can we optimize the strcat here (by remembering the position where to append)?

Or maybe we could unify this completely with AppendToErrorMessageBuffer (in asan_report.cc), which basically does the same thing. We could only have a single buffer to log into.

lib/sanitizer_common/sanitizer_printf.cc
283 ↗(On Diff #42344)

This means that CallPrintfAndReportCallback is now called on a color-less string. I'm actually in favor of this change, but we should make sure everyone's okay with it.

zaks.anna marked an inline comment as done.Dec 15 2015, 3:30 PM
zaks.anna added inline comments.
lib/sanitizer_common/sanitizer_mac.h
49 ↗(On Diff #42344)

Don't we need a lock here?

Yes, we need it. Will address.

Can we optimize the strcat here (by remembering the position where to append)?

I am not convinced that increasing code complexity is worth it in this case. This is logging code...

Or maybe we could unify this completely with
AppendToErrorMessageBuffer (in asan_report.cc), which basically does > the same thing. We could only have a single buffer to log into.

Currently, AppendToErrorMessageBuffer is ASan specific. We should log output from any sanitizer.

lib/sanitizer_common/sanitizer_printf.cc
283 ↗(On Diff #42344)

Yes, calling CallPrintfAndReportCallback on a color-less string seems to be the right thing to do, at least to me.

I can update the commit message to call this out.

zaks.anna updated this revision to Diff 42934.Dec 15 2015, 3:55 PM
zaks.anna marked an inline comment as done.

Added the lock.

kubamracek edited edge metadata.Dec 16 2015, 3:13 AM

LGTM with a nit.

lib/sanitizer_common/sanitizer_mac.h
52 ↗(On Diff #42934)

Clang-format

samsonov accepted this revision.Dec 16 2015, 9:36 AM
samsonov edited edge metadata.

LGTM

lib/sanitizer_common/sanitizer_printf.cc
283 ↗(On Diff #42934)

Yes, I think it's fine.

This revision is now accepted and ready to land.Dec 16 2015, 9:36 AM
This revision was automatically updated to reflect the committed changes.