[PATCH] D112376: [Support] [Windows] Use the regular RemoveFileOnSignal() mechanism on Windows too

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 24 05:03:14 PDT 2021


mstorsjo created this revision.
mstorsjo added reviewers: rnk, amccarth, rdwampler, jhenderson, aganea, akhuang, probinson.
Herald added subscribers: dexonsmith, hiraditya.
mstorsjo requested review of this revision.
Herald added a project: LLVM.

This effectively reverts 3ecd20430cace7eb9e78ef0a9ff9cc95a377feb9
(together with some further fixes from
881ba104656c40098d4bc90c52613c08136f0fe1).

The original change away from RemoveFileOnSignal() didn't say why
what was gained, other than "We won't see the temp file no more.".

All use of FILE_FLAG_DELETE_ON_CLOSE or FILE_DISPOSITION_INFO
with DeleteFile=true, and the DELETE access flag, cause various
issues. The original FILE_FLAG_DELETE_ON_CLOSE (in
3ecd20430cace7eb9e78ef0a9ff9cc95a377feb9) had to be worked around
when deciding to keep the file (to cancel the effect of the flag).
This was reworked in 881ba104656c40098d4bc90c52613c08136f0fe1 / D48051 <https://reviews.llvm.org/D48051>
as that approach broke some cases when memory mapping and closing
files (as used in LTO).

This further broke cases when writing temp files on network shares,
worked around in 79657e2339b58bc01fe1b85a448bb073d57d90bb <https://reviews.llvm.org/rG79657e2339b58bc01fe1b85a448bb073d57d90bb> / D81803 <https://reviews.llvm.org/D81803>,
which then broke some cases on Windows 7, worked around in
64ab2b6825c5aeae6e4afa7ef0829b89a6828102 <https://reviews.llvm.org/rG64ab2b6825c5aeae6e4afa7ef0829b89a6828102>. After that, the temp
files were left behind on network shares, even after calling
TempFile::discard(). Fixes for this were attempted in D111875 <https://reviews.llvm.org/D111875>,
but would end up needing to set the DELETE access flag when opening
files for writing in general (or further splitting up/changing the
OF_Delete flag), which breaks when opening a file multiple times
(see discussion in D111875 <https://reviews.llvm.org/D111875>).

Thus simply backtrack and abandon the whole use of delete-on-close
flags on Windows, and use the same RemoveFileOnSignal() mechanism
as on Unix. (The RemoveFileOnSignal() mechanism was still used for
other temp files, not created by `TempFile::create`.)

After this change, one could maybe also reinstante
51c63bb7efff5f90cd3894dc2b6f73a614dbfb96 (which was reverted as
part of 881ba104656c40098d4bc90c52613c08136f0fe1 / D48051 <https://reviews.llvm.org/D48051>), to
use `TempFile` in the implementation of `LockFileManager`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112376

Files:
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/Windows/Path.inc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112376.381776.patch
Type: text/x-patch
Size: 5637 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211024/31af2021/attachment.bin>


More information about the llvm-commits mailing list