[PATCH] D51006: LTO: make tempfiles in LTO cache subject to pruning

Bob Haarman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 20 16:11:55 PDT 2018


inglorion added a comment.

> Do you know why the temporary files are being left on disk? I wouldn't have expected that to happen because they are being created with delete-on-close.

Yes. The problem is that there are two races with delete on close. More discussion and analysis is on PR38616, but it boils down to:

1. The first race is between when we open the file and we set the DeleteFile flag. We can't use the alternative of opening the file with the FILE_DELETE_ON_CLOSE flag, because we can't clear that one (and so there would be no way to keep a temporary file).

2. The second race is between when we clear the DeleteFile flag and we rename the file (in the renaming version of TempFile::keep()). We can't atomically perform the flag change and the rename, and we can't do the flag change after the name because this causes everyone who opens the file with its non-temporary name to fail with ERROR_ACCESS_DENIED until we clear the flag (this breaks large parts of the LLVM test suite).

Anyway, thanks for pointing out the reason why the temporary files are named so as to avoid the pruner. I'll do some more thinking.


https://reviews.llvm.org/D51006





More information about the llvm-commits mailing list