All,
Look at SharedMemoryBase::mapObject() - it maps memory range aligned by system allocation
page size. This is explicit requirement of both mmap() and MapViewOfFile(). But it also
aligns end of the mapped range - and this is a problem, as this point could be out of the
mapped file size. I see no such requirement in docs:
- mmap:
https://man7.org/linux/man-pages/man2/mmap.2.html
in section ERRORS:
---
EINVAL We don't like addr, length, or offset (e.g., they are too
large, or not aligned on a page boundary).
---
it mention "length" but in EXAMPLES it uses aligned value for "offset" only
and "length" could be evaluated as part of file from offset to the end,
if not set.
- MapViewOfFile
https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-mapviewoffile
makes no special requirements for the "dwNumberOfBytesToMap" parameter and says:
---
If this parameter is 0 (zero), the mapping extends from the specified offset to the end of the file mapping.
---
So, the question is - do we really need to align end of mapping range by the system
page size ? Test on Windows shows it is not necessary (as expected).
Regards,
Vlad