This is an archive of the discontinued LLVM Phabricator instance.

tsan: always handle closing of file descriptors
ClosedPublic

Authored by dvyukov on Dec 21 2021, 1:39 AM.

Details

Summary

If we miss both close of a file descriptor and a subsequent open
if the same file descriptor number, we report false positives
between operations on the old and on the new descriptors.

There are lots of ways to create new file descriptors, but for closing
there is mostly close call. So we try to handle at least it.
However, if the close happens in an ignored library, we miss it
and start reporting false positives.

Handle closing of file descriptors always, even in ignored libraries
(as we do for malloc/free and other critical functions).
But don't imitate memory accesses on close for ignored libraries.

FdClose checks validity of the fd (fd >= 0) itself,
so remove the excessive checks in the callers.

Diff Detail

Unit TestsFailed

Event Timeline

dvyukov requested review of this revision.Dec 21 2021, 1:39 AM
dvyukov created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 21 2021, 1:39 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
melver accepted this revision.Dec 21 2021, 3:42 AM
melver added inline comments.
compiler-rt/lib/tsan/rtl/tsan_interceptors.h
39

Just 'inline'? (like in_symbolizer() above -- otherwise every TU that outlines it gets its own copy)

This revision is now accepted and ready to land.Dec 21 2021, 3:42 AM
dvyukov updated this revision to Diff 395647.Dec 21 2021, 4:35 AM

remove 'static'

This revision was landed with ongoing or failed builds.Dec 21 2021, 4:35 AM
This revision was automatically updated to reflect the committed changes.
dvyukov marked an inline comment as done.Dec 21 2021, 4:35 AM