Re: [boost] [bug report]boost-sandbox.interprocess::mapped_region.hpp

Hi, Oh.....my dirty solution is wrong too....
You are right. If the mapping address is not the desired one, the cleanup is wrong. Your solution, moving the following lines
============================================== //Check for fixed mapping error if(address && (m_base != (void*)address)){ error_info err = system_error_code(); this->priv_close(); // bug here throw interprocess_exception(err); } ==============================================
to the end of the function should fix it (since the object would be in an stable state)
If moving above code snip to the end of function will cause another problem....evaluation of (m_base != (void* )address) is false always. my suggest is m_base is the return value of mmap(...) not the user want. but get_address() return m_base + m_extra_offset not m_base. it's more clear than use modified m_base everywhere. sorry for the wrong information last email. Wilbur Lang

Wilbur Lang wrote:
Hi,
Oh.....my dirty solution is wrong too....
The solution might be this: m_base = mmap ( (void*)address , static_cast<std::size_t>(m_extra_offset + m_size) , prot , flags , mapping.get_mapping_handle() , offset - m_extra_offset); //Check if mapping was successful if(m_base == MAP_FAILED){ error_info err = system_error_code(); this->priv_close(); throw interprocess_exception(err); } //Calculate new base for the user void *old_base = m_base; m_base = static_cast<char*>(m_base) + m_extra_offset; m_offset = offset; m_size = size; //Check for fixed mapping error if(address && (old_base != (void*)address)){ error_info err = system_error_code(); this->priv_close(); throw interprocess_exception(err); } The mapping address is cached and tested when the object is in a stable state, so that priv_close() can properly clean all the resources. Regards, Ion
participants (2)
-
Ion Gaztañaga
-
Wilbur Lang