Avoid crashing by not mmap'ing files on network mounted file systems.
authorGreg Clayton <gclayton@apple.com>
Mon, 23 Feb 2015 23:47:09 +0000 (23:47 +0000)
committerGreg Clayton <gclayton@apple.com>
Mon, 23 Feb 2015 23:47:09 +0000 (23:47 +0000)
commit736888c84b51c7cf1f8eccea6738ad54503c2d0a
treee3d33c87985a4395053a078f387abea669744315
parent18c243b933740506b3262e56ef6f9a3a6e4afc08
Avoid crashing by not mmap'ing files on network mounted file systems.

This is implemented by making a new FileSystem function:

bool
FileSystem::IsLocal(const FileSpec &spec)

Then using this in a new function:

DataBufferSP
FileSpec::MemoryMapFileContentsIfLocal(off_t file_offset, size_t file_size) const;

This function only mmaps data if the file is a local file since that means we can reliably page in data. We were experiencing crashes where people would use debug info files on network mounted file systems and that mount would go away and cause the next access to a page that wasn't paged in to crash LLDB.

We now avoid this by just copying the data into a heap buffer and keeping a permanent copy to avoid the crash. Updated all previous users of FileSpec::MemoryMapFileContentsIfLocal() in ObjectFile subclasses over to use the new FileSpec::MemoryMapFileContentsIfLocal() function.

<rdar://problem/19470249>

llvm-svn: 230283
lldb/include/lldb/Host/FileSpec.h
lldb/include/lldb/Host/FileSystem.h
lldb/source/Host/common/FileSpec.cpp
lldb/source/Host/posix/FileSystem.cpp
lldb/source/Host/windows/FileSystem.cpp
lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp