Boost logo

Boost :

From: Wilbur Lang (wilburlang_at_[hidden])
Date: 2007-07-17 07:08:07


another problems in the same file.

A) problem of align
because mmap() requires:
1. offset should be a multiple of page size
2. the address start must be a multiple of page size.
we have to align the offset and start to page size.

for code snip begin from line 444,
      address = static_cast<const char*>(address) - m_extra_offset;

you make a wrong alignment for address.

for example construct a mapped_region object with offset=1 and
address=0x3f000002. m_extra_offset is 1, and calculated address is
0x3f000001 which is not page size aligned. another member variable have
to imported to record the offset of address and m_base.

B) problem of m_size under windows
in some case, the m_size is zero (0) under windows.

code snipp begin at line 327 (mapped_region::flush)
    if(numbytes == 0) {
        numbytes = m_size - offset;
if m_size is 0, numbytes is a negative.

for the problem A, I do suggest m_base/m_offset is the real value not
adjusted value. then we just adjust this value in
get_size()/get_address()/get_offset() like this:

    if(m_size == 0)
        return m_size;
    return m_size - m_extra_offset;

    return static_cast<char* >(m_base) + m_extra_offset;

    return m_offset + m_extra_offset;

Best Regards,

Wilbur Lang

Boost list run by bdawes at, gregod at, cpdaniel at, john at