[LLDB] Fix AddressSanitizer failure in MemoryCache
authorPaolo Severini <paolosev@microsoft.com>
Thu, 27 Feb 2020 19:17:10 +0000 (11:17 -0800)
committerPaolo Severini <paolosev@microsoft.com>
Thu, 27 Feb 2020 19:17:10 +0000 (11:17 -0800)
commit256e61699b19c8e3545c948547c12872a8567250
treef0ad341009a4f6e7776597ec2aaa4801a3bee785
parent4a966e5dd75160a7df0c7231e4c760a2bb127112
[LLDB] Fix AddressSanitizer failure in MemoryCache

The lldb sanitizer bot is flagging a container-overflow error after we
introduced test TestWasm.py. MemoryCache::Read didn't behave correctly
in case of partial reads that can happen with object files whose size is
smaller that the cache size. It should return the actual number of bytes
read and not try to fill the buffer with random memory.
Module::GetMemoryObjectFile needs to be modified accordingly, to resize
its buffer to only the size that was read.

Differential Revision: https://reviews.llvm.org/D75200
lldb/source/Core/Module.cpp
lldb/source/Target/Memory.cpp