[cfe-dev] libclang locking files for write/delete on windows
Ivan Koster
ivankoster at gmail.com
Tue Dec 9 04:03:38 PST 2014
I've experimented a bit with Sysinternals Process Monitor.
The issue seems definetly linked to file size. I took dummy.h and ran it
through the monitor. (bad trace)
Then I took dummy.h, removed 90% of the lines from the bottom, and also ran
it through the monitor. (good trace)
At some point the traces diverge:
The good trace calls the operations ReadFile, CloseFile and is done.
The bad trace calls CreateFileMapping (which seems to fail with "FILE
LOCKED WITH ONLY READERS"), QueryStandardInformationFile,
CreateFileMapping, Close File.
So even though the bad trace does seem to close the filehandles, the file
remains locked for write or delete.
I've also recorded the stack traces of libclang where the two diverge.
badcall.csv:
https://drive.google.com/file/d/0B8xFlIzMhHcpZGRpTG9CcDRNSk0/view?usp=sharing
goodcall.csv:
https://drive.google.com/file/d/0B8xFlIzMhHcpaEt0UFEzRVJWUjg/view?usp=sharing
You can throw these in your favourite diff tool.
Around some function called llvm MemoryBuffer getOpenFile things start to
go different.
I have no experience yet with llvm code base to pinpoint this.
I can also upload the Process Monitor log trace files (*.PML) if someone
needs them to analyze.
On Mon, Dec 8, 2014 at 8:32 PM, Kim Gräsman <kim.grasman at gmail.com> wrote:
> On Mon, Dec 8, 2014 at 8:02 PM, Reid Kleckner <rnk at google.com> wrote:
> > We use this code to open files for reading on Windows:
> >
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Path.inc?view=markup#l756
> >
> > See the FILE_SHARE_READ | FILE_SHARE_WRITE flags. We could add
> > FILE_SHARE_DELETE and see if that fixes your problem.
> >
> > Note that locking files against writes or deletions while reading them is
> > pretty common on Windows. MSVC, for example, does this to sources and
> > headers during compilation.
>
> Oh, and here's another one:
>
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Path.inc?view=markup#l554
>
> It seems to require exclusive access if Mode == readonly, which seems
> a little backwards.
>
> This probably isn't used in this code path, though.
>
> - Kim
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141209/0f8c1d77/attachment.html>
More information about the cfe-dev
mailing list