[PATCH] D54995: [MemoryBuffer] By default assume that all files are volatile to prevent unintended file locks
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 30 09:57:58 PST 2018
ilya-biryukov added a comment.
In D54995#1312617 <https://reviews.llvm.org/D54995#1312617>, @lebedev.ri wrote:
> Passing-by thought, feel free to ignore: this seems to so far only affect windows only?
> So the fix shouldn't probably pessimize all other arches? (and maybe even non-clangd)
Sure, we'll make sure to keep the compiler and libclang/clangd on non-windows archs still use memory-mapped files.
I even have hopes there are ways to workaround the locks on Windows, but I'm probably too optimistic.
In D54995#1312532 <https://reviews.llvm.org/D54995#1312532>, @yvvan wrote:
> According to https://msdn.microsoft.com/en-us/2e9c3174-af48-4fa3-9f6a-fb62b23ed994 - "Unmapping a mapped view of a file invalidates the range occupied by the view in the address space of the process and makes the range available for other allocations".
> Also as far as i understand from https://msdn.microsoft.com/en-us/library/ms810613.aspx mapped files can only be edited in other apps as mapped files opened with the same name (OpenFileMapping).
I couldn't find any reference to file locking in those docs (I haven't thoroughly read the second one, though, so I might've missed it). Will check out your example program, thanks for posting it!
In D54995#1314133 <https://reviews.llvm.org/D54995#1314133>, @yvvan wrote:
> No success with unmapping. Buffers are hold by PCMCache in Preprocessor (and the same one in ASTReader) and if I clean them then SourceManger crashed sooner or later on some call that gets data from external files.
> So far I have no steps to reproduce the lock on user file so I don't currently know if I try something else.
Unmapping definitely won't work, there are a ton of operations that might require the file contents. I don't think we can make clang code avoid reading the files it previously had opened.
If no workaround works, reading files on windows instead of memory-mapping them is probably the only option for interactive editors.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54995/new/
https://reviews.llvm.org/D54995
More information about the cfe-commits
mailing list