Fix a use-after-unmap bug in /proc/self/maps caching. The cached buffer was occasionally deleted in the MemoryMappingLayout destructor.

llvm-svn: 169335
This commit is contained in:
Alexander Potapenko 2012-12-04 23:30:00 +00:00
parent a8f026e2d4
commit 0a4e0f6d35
1 changed files with 5 additions and 1 deletions

View File

@ -236,7 +236,11 @@ MemoryMappingLayout::MemoryMappingLayout() {
} }
MemoryMappingLayout::~MemoryMappingLayout() { MemoryMappingLayout::~MemoryMappingLayout() {
UnmapOrDie(proc_self_maps_.data, proc_self_maps_.mmaped_size); // Only unmap the buffer if it is different from the cached one. Otherwise
// it will be unmapped when the cache is refreshed.
if (proc_self_maps_.data != cached_proc_self_maps_.data) {
UnmapOrDie(proc_self_maps_.data, proc_self_maps_.mmaped_size);
}
} }
void MemoryMappingLayout::Reset() { void MemoryMappingLayout::Reset() {