Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion lib/Serialization/SerializedModuleLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,25 @@ std::error_code SerializedModuleLoaderBase::openModuleFile(
}

// Actually load the file and error out if necessary.
//
// Use the default arguments except for IsVolatile. Force avoiding the use of
// mmap to workaround issues on NFS when the swiftmodule file loaded changes
// on disk while it's in use.
//
// In practice, a swiftmodule file can chane when a client uses a
// swiftmodule file from a framework while the framework is recompiled and
// installed over existing files. Or when many processes rebuild the same
// module interface.
//
// We have seen these scenarios leading to deserialization errors that on
// the surface look like memory corruption.
//
// rdar://63755989
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ModuleOrErr =
FS.getBufferForFile(ModulePath);
FS.getBufferForFile(ModulePath,
/*FileSize=*/-1,
/*RequiresNullTerminator=*/true,
/*IsVolatile=*/true);
if (!ModuleOrErr)
return ModuleOrErr.getError();

Expand Down