Commit 119205fc authored by Alexandr Ilin's avatar Alexandr Ilin Committed by Commit Bot

Use actual mapping size when unmapping a region

SharedMemoryMapping::Unmap() call passes a mapping size to the munmap() or a
similar system call on some platforms. The actual size of a mapping is stored
in the SharedMemoryMapping::mapped_size_ but the SharedMemoryMapping::size_
which contains the logical size of the mapping has been mistakenly used instead.

This bug is not severe though because the mapped_size_/size_ mismatch exists
only on Windows and Windows system call for unmapping doesn't accept the size.

Change-Id: Id25c3dce6f0e2ea78d885e76e936572d4e5d2d52
Reviewed-on: https://chromium-review.googlesource.com/1241054Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Alexandr Ilin <alexilin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593695}
parent 276e662d
...@@ -74,15 +74,16 @@ void SharedMemoryMapping::Unmap() { ...@@ -74,15 +74,16 @@ void SharedMemoryMapping::Unmap() {
DPLOG(ERROR) << "UnmapViewOfFile"; DPLOG(ERROR) << "UnmapViewOfFile";
#elif defined(OS_FUCHSIA) #elif defined(OS_FUCHSIA)
uintptr_t addr = reinterpret_cast<uintptr_t>(memory_); uintptr_t addr = reinterpret_cast<uintptr_t>(memory_);
zx_status_t status = zx::vmar::root_self()->unmap(addr, size_); zx_status_t status = zx::vmar::root_self()->unmap(addr, mapped_size_);
if (status != ZX_OK) if (status != ZX_OK)
ZX_DLOG(ERROR, status) << "zx_vmar_unmap"; ZX_DLOG(ERROR, status) << "zx_vmar_unmap";
#elif defined(OS_MACOSX) && !defined(OS_IOS) #elif defined(OS_MACOSX) && !defined(OS_IOS)
kern_return_t kr = mach_vm_deallocate( kern_return_t kr = mach_vm_deallocate(
mach_task_self(), reinterpret_cast<mach_vm_address_t>(memory_), size_); mach_task_self(), reinterpret_cast<mach_vm_address_t>(memory_),
mapped_size_);
MACH_DLOG_IF(ERROR, kr != KERN_SUCCESS, kr) << "mach_vm_deallocate"; MACH_DLOG_IF(ERROR, kr != KERN_SUCCESS, kr) << "mach_vm_deallocate";
#else #else
if (munmap(memory_, size_) < 0) if (munmap(memory_, mapped_size_) < 0)
DPLOG(ERROR) << "munmap"; DPLOG(ERROR) << "munmap";
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment