[PATCH] D48051: LTO: Work around a Windows kernel bug by keeping file handles open for memory mapped files.

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 11 16:26:59 PDT 2018


zturner added a comment.

In https://reviews.llvm.org/D48051#1129116, @pcc wrote:

> In https://reviews.llvm.org/D48051#1129109, @zturner wrote:
>
> > In https://reviews.llvm.org/D48051#1129100, @pcc wrote:
> >
> > > > I don't think that would prevent other processes from opening the file.  Both processes just have to make sure they both specify `FILE_SHARE_DELETE`.
> > >
> > > As I wrote in my message to Bob that doesn't seem to work. According to process monitor the second process fails to open the file with "DELETE PENDING".
> >
> >
> > That's because a handle has been opened with `FILE_FLAG_DELETE_ON_CLOSE` and then subsequently closed.  As soon as you close a file that has been openend with that flag, no other opens can happen on the file.  That's why I suggested transferring ownership of it.
>
>
> But we need to close the handle to clear `FILE_FLAG_DELETE_ON_CLOSE`. Or are you suggesting that we do this:
>
> - open file with `FILE_FLAG_DELETE_ON_CLOSE`
> - map the file
> - use it
> - unmap it
> - do magic to clear `FILE_FLAG_DELETE_ON_CLOSE` ? I'm not sure that would be simpler because it would mean transferring ownership back to the `TempFile`.


If you could guarantee that the person who originally opened it with `FILE_FLAG_DELETE_ON_CLOSE` could outlive any other process that may wish to share it, then you could just do:

1. Process A - Open it with `FILE_FLAG_DELETE_ON_CLOSE`.
2. Processes https://reviews.llvm.org/B1, https://reviews.llvm.org/B2, ..., Bn - Open it with `FILE_SHARE_DELETE` (this should work)
3. Wait for all those processes to exit.
4. Process A - close the file.


https://reviews.llvm.org/D48051





More information about the llvm-commits mailing list