[clang][modules] Fix filesystem races in ModuleManager#131354
Closed
jansvoboda11 wants to merge 1 commit intollvm:mainfrom
Closed
[clang][modules] Fix filesystem races in ModuleManager#131354jansvoboda11 wants to merge 1 commit intollvm:mainfrom
ModuleManager#131354jansvoboda11 wants to merge 1 commit intollvm:mainfrom
Conversation
5156da2 to
7945795
Compare
Member
|
Thanks for the PR, testing for the use case described in #130795 it seems to fix the issue! tl;dr I'm building LLVM+Clang+libcxx with and then use the built Using |
7e8e883 to
aec5c19
Compare
a3e3fd5 to
0054f8a
Compare
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
0054f8a to
59263d8
Compare
59263d8 to
eb814bf
Compare
Contributor
Author
|
Superseded by #185765 that doesn't rely on path normalization. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
ModuleManagerusesFileEntryobjects to uniquely identify module files. This requires first consulting theFileManager(and therefore the file system) when loading PCM files. This is problematic, as this might load a different PCM file to what's already in theInMemoryModuleCacheand fail the size and mtime checks. (This is a bit artificial, but that could happen when using implicit modules without PCM signatures, withFileManagersharing disabled, and without a caching VFS.)This PR changes things so that module files are identified by their file system path. This removes the need of knowing the file entry at the start and allows us to fix the race. The downside is that we no longer get the
FileManagerinode-based uniquing, meaning symlinks in the module cache no longer work. I think this is fine, since Clang itself never creates symlinks in that directory. Moreover, we already had to work around filesystems recycling inode numbers, so this actually seems like a win to me (and resolves a long-standing FIXME-like comment).Note that this change also requires
ModuleManagerto use consistent paths to refer to module files. This might be problematic if there are concurrent Clang processes operating on the same module cache directory but with different spellings of its path - theIMPORTrecords in PCM files will be valid and consistent within single process, but may break uniquing in another process. We currently only do path-based canonicalization instead of more robust solution of something like real paths.