File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -347,8 +347,25 @@ std::error_code SerializedModuleLoaderBase::openModuleFile(
347347 }
348348
349349 // Actually load the file and error out if necessary.
350+ //
351+ // Use the default arguments except for IsVolatile. Force avoiding the use of
352+ // mmap to workaround issues on NFS when the swiftmodule file loaded changes
353+ // on disk while it's in use.
354+ //
355+ // In practice, a swiftmodule file can chane when a client uses a
356+ // swiftmodule file from a framework while the framework is recompiled and
357+ // installed over existing files. Or when many processes rebuild the same
358+ // module interface.
359+ //
360+ // We have seen these scenarios leading to deserialization errors that on
361+ // the surface look like memory corruption.
362+ //
363+ // rdar://63755989
350364 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ModuleOrErr =
351- FS.getBufferForFile (ModulePath);
365+ FS.getBufferForFile (ModulePath,
366+ /* FileSize=*/ -1 ,
367+ /* RequiresNullTerminator=*/ true ,
368+ /* IsVolatile=*/ true );
352369 if (!ModuleOrErr)
353370 return ModuleOrErr.getError ();
354371
You can’t perform that action at this time.
0 commit comments