It appears that a potential race between the cache client and the cache
pruner that I thought was unlikely actually happened in practice [1].
Try to avoid the race condition by opening the temporary file before
renaming it. Do this only on non-Windows platforms because we cannot
rename open files on Windows.
Details
Details
- Reviewers
tejohnson mehdi_amini - Commits
- rG37c747498d98: [CodeView] Don't output S_UDTs for nested typedefs.
rGd0e9c167d8a6: LTO: Try to open cache files before renaming them.
rLLD312567: LTO: Try to open cache files before renaming them.
rL312583: [CodeView] Don't output S_UDTs for nested typedefs.
rL312567: LTO: Try to open cache files before renaming them.
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
I think you actually can rename open files on Windows. Or at least, you can try to. I'll have to dig in when I have a bit more time though to see if there's any weird things we need to be aware of when doing it, or casse where it won't work.
But basically, what you do is call SetFileInformationByHandle and set the FileInformationClass parameter to FileRenameInfo, and fill out a FILE_RENAME_INFO structure to pass for the 3rd argument.
Comment Actions
LGTM
llvm/include/llvm/LTO/Caching.h | ||
---|---|---|
27 ↗ | (On Diff #113632) | The comment is not accurate I believe: the Path didn't exist when when the memory buffer was created, and it was never opened using this path. |
Comment Actions
Thanks, I've left a FIXME about renaming the file in the way you've suggested.
llvm/include/llvm/LTO/Caching.h | ||
---|---|---|
27 ↗ | (On Diff #113632) | Reworded this comment. |