This is an archive of the discontinued LLVM Phabricator instance.

tsan: lock ScopedErrorReportLock around fork
ClosedPublic

Authored by dvyukov on Jul 15 2021, 2:21 AM.

Details

Summary

Currently we don't lock ScopedErrorReportLock around fork
and it mostly works becuase tsan has own report_mtx that
is locked around fork and tsan reports.
However, sanitizer_common code prints some own reports
which are not protected by tsan's report_mtx. So it's better
to lock ScopedErrorReportLock explicitly.

Diff Detail

Event Timeline

dvyukov requested review of this revision.Jul 15 2021, 2:21 AM
dvyukov created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2021, 2:21 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
melver added inline comments.Jul 15 2021, 6:06 AM
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp
256

Shouldn't the ACQUIRE() annotation go in the header, so that callers see this?

289–290

Any reason why CHECK_LOCKED is not added in this change, i.e. will it be added later?

dvyukov updated this revision to Diff 358999.Jul 15 2021, 8:56 AM

improve thread safety annotations

dvyukov marked an inline comment as done.Jul 15 2021, 8:58 AM
dvyukov added inline comments.
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp
256

Well, yes. The reason I put it here is that CommonSanitizerReportMutex is static in this source file, so there is no way to refer to it in the header file. I already encountered this situation in several other places, I guess the annotations were developed with the classical C++ OOP style in mind.

I've moved the mutex to the header and improved the annotations.

PTAL

melver accepted this revision.Jul 15 2021, 9:09 AM
This revision is now accepted and ready to land.Jul 15 2021, 9:09 AM
This revision was automatically updated to reflect the committed changes.