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 --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp') diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index bf466c7ee9b..1b49aab0df1 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -365,7 +365,7 @@ ObjectFileELF::CreateInstance (const lldb::ModuleSP &module_sp, { if (!data_sp) { - data_sp = file->MemoryMapFileContents(file_offset, length); + data_sp = file->MemoryMapFileContentsIfLocal(file_offset, length); data_offset = 0; } @@ -376,7 +376,7 @@ ObjectFileELF::CreateInstance (const lldb::ModuleSP &module_sp, { // Update the data to contain the entire file if it doesn't already if (data_sp->GetByteSize() < length) { - data_sp = file->MemoryMapFileContents(file_offset, length); + data_sp = file->MemoryMapFileContentsIfLocal(file_offset, length); data_offset = 0; magic = data_sp->GetBytes(); } @@ -636,7 +636,7 @@ ObjectFileELF::GetModuleSpecifications (const lldb_private::FileSpec& file, size_t section_header_end = header.e_shoff + header.e_shnum * header.e_shentsize; if (section_header_end > data_sp->GetByteSize()) { - data_sp = file.MemoryMapFileContents (file_offset, section_header_end); + data_sp = file.MemoryMapFileContentsIfLocal (file_offset, section_header_end); data.SetData(data_sp); } @@ -678,7 +678,7 @@ ObjectFileELF::GetModuleSpecifications (const lldb_private::FileSpec& file, size_t program_headers_end = header.e_phoff + header.e_phnum * header.e_phentsize; if (program_headers_end > data_sp->GetByteSize()) { - data_sp = file.MemoryMapFileContents(file_offset, program_headers_end); + data_sp = file.MemoryMapFileContentsIfLocal(file_offset, program_headers_end); data.SetData(data_sp); } ProgramHeaderColl program_headers; @@ -693,7 +693,7 @@ ObjectFileELF::GetModuleSpecifications (const lldb_private::FileSpec& file, if (segment_data_end > data_sp->GetByteSize()) { - data_sp = file.MemoryMapFileContents(file_offset, segment_data_end); + data_sp = file.MemoryMapFileContentsIfLocal(file_offset, segment_data_end); data.SetData(data_sp); } @@ -702,7 +702,7 @@ ObjectFileELF::GetModuleSpecifications (const lldb_private::FileSpec& file, else { // Need to map entire file into memory to calculate the crc. - data_sp = file.MemoryMapFileContents (file_offset, SIZE_MAX); + data_sp = file.MemoryMapFileContentsIfLocal (file_offset, SIZE_MAX); data.SetData(data_sp); gnu_debuglink_crc = calc_gnu_debuglink_crc32 (data.GetDataStart(), data.GetByteSize()); } -- cgit v1.2.3