This is an archive of the discontinued LLVM Phabricator instance.

tsan: fix false positive during fd close
ClosedPublic

Authored by dvyukov on Mar 7 2022, 11:43 AM.

Details

Summary

FdClose is a subjet to the same atomicity problem as MemoryRangeFreed
(memory state is not "monotoic" wrt race detection).
So we need to lock the thread slot in FdClose the same way we do
in MemoryRangeFreed.
This fixes the modified stress.cpp test.

Diff Detail

Event Timeline

dvyukov created this revision.Mar 7 2022, 11:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2022, 11:43 AM
dvyukov requested review of this revision.Mar 7 2022, 11:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2022, 11:43 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
vitalybuka accepted this revision.Mar 7 2022, 12:01 PM
This revision is now accepted and ready to land.Mar 7 2022, 12:01 PM
melver accepted this revision.Mar 7 2022, 12:26 PM
melver added inline comments.
compiler-rt/lib/tsan/rtl/tsan_fd.cpp
211

There doesn't appear to be an actual comment change here - clang-format changed this?

dvyukov added inline comments.Mar 8 2022, 1:39 AM
compiler-rt/lib/tsan/rtl/tsan_fd.cpp
211

My patch changes indentation level, so 'arc diff' reformatted it as it crossed 80 cols boundary I guess.

This revision was automatically updated to reflect the committed changes.