Opened 13 years ago

Closed 13 years ago

#3417 closed Bugs (fixed)

boost::interprocess::managed_shared_memory::belongs_to_segment returns incorrect value.

Reported by: Lénaïc Huard <lhuard@…> Owned by: Ion Gaztañaga
Milestone: Boost 1.41.0 Component: interprocess
Version: Boost 1.40.0 Severity: Problem
Keywords: Cc:

Description

Hello,

It seems that boost::interprocess::managed_shared_memory::belongs_to_segment implementation is not correct. It returns true for chunks of memory that don't belong to the shared memory segment providing it's lying at a higher address.

Looking at https://svn.boost.org/trac/boost/browser/trunk/boost/interprocess/detail/managed_memory_impl.hpp shows:

262

!Returns true if the address belongs to the managed memory segment

263

bool belongs_to_segment (const void *ptr) const

264

{

265

return ptr >= this->get_address() &&

266

ptr < (reinterpret_cast<const char*>(ptr) + this->get_size());

267

}

It would be more logical to have:

!Returns true if the address belongs to the managed memory segment bool belongs_to_segment (const void *ptr) const {

return ptr >= this->get_address() &&

ptr < (reinterpret_cast<const char *>(this->get_address()) + this->get_size());

}

Change History (1)

comment:1 by Lénaïc Huard <lhuard@…>, 13 years ago

Resolution: fixed
Status: newclosed

Implemented in 1.41.

Note: See TracTickets for help on using tickets.