From 736888c84b51c7cf1f8eccea6738ad54503c2d0a Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Mon, 23 Feb 2015 23:47:09 +0000 Subject: 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. llvm-svn: 230283 --- .../Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp') diff --git a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp index 1e2a0c721ff..87bf75321ed 100644 --- a/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ b/lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -364,7 +364,7 @@ ObjectContainerBSDArchive::CreateInstance // Map the entire .a file to be sure that we don't lose any data if the file // gets updated by a new build while this .a file is being used for debugging - DataBufferSP archive_data_sp (file->MemoryMapFileContents(file_offset, length)); + DataBufferSP archive_data_sp (file->MemoryMapFileContentsIfLocal(file_offset, length)); lldb::offset_t archive_data_offset = 0; Archive::shared_ptr archive_sp (Archive::FindCachedArchive (*file, @@ -570,7 +570,7 @@ ObjectContainerBSDArchive::GetModuleSpecifications (const lldb_private::FileSpec if (!archive_sp) { set_archive_arch = true; - DataBufferSP data_sp (file.MemoryMapFileContents(file_offset, file_size)); + DataBufferSP data_sp (file.MemoryMapFileContentsIfLocal(file_offset, file_size)); data.SetData (data_sp, 0, data_sp->GetByteSize()); archive_sp = Archive::ParseAndCacheArchiveForFile(file, ArchSpec(), file_mod_time, file_offset, data); } -- cgit v1.2.3