[PATCH] D31063: LTO: Fix a potential race condition in the caching API.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 17 10:56:46 PDT 2017
pcc added a comment.
Is there a rename syscall immediately before the open syscall? If that is the case, the fatal error is probably coming from Caching.cpp:73, which is unexpected because we just put a file in place with the correct name, so maybe something is going on with the filesystem on that machine?
The other alternative is that the error is coming from Caching.cpp:41, and in that case the file not existing is expected. If the file does not exist we are supposed to fail the if condition on line 40 and create a new cache entry.
The only explanation I can think of is that there is some sort of bug in your stdlib that causes the if condition to succeed. What happens if you apply this patch?
diff --git a/llvm/lib/LTO/Caching.cpp b/llvm/lib/LTO/Caching.cpp
index d8b91c48ee3..c24540e1860 100644
--- a/llvm/lib/LTO/Caching.cpp
+++ b/llvm/lib/LTO/Caching.cpp
@@ -37,7 +37,8 @@ Expected<NativeObjectCache> lto::localCache(StringRef CacheDirectoryPath,
return AddStreamFn();
}
- if (MBOrErr.getError() != std::errc::no_such_file_or_directory)
+ if (MBOrErr.getError() != std::errc::no_such_file_or_directory &&
+ MBOrErr.getError().message() != "No such file or directory")
report_fatal_error(Twine("Failed to open cache file ") + EntryPath +
": " + MBOrErr.getError().message() + "\n");
Repository:
rL LLVM
https://reviews.llvm.org/D31063
More information about the llvm-commits
mailing list