Boost C++ Libraries: Ticket #11912: boost::interprocess::flat_map use of vector::priv_forward_range_insert_expand_backwards may cause boost::container::move with same source and destination https://svn.boost.org/trac10/ticket/11912 <p> boost::interprocess::flat_map use of vector::priv_forward_range_insert_expand_backwards may cause boost::container::move with same source and destination. </p> <p> If an allocator that supports expand_backwards or expand_forwards is used and either of the operation succeeds with the capacity of increasing by the count of elements being inserted, and the elements being inserted happen to be placed in the direction of the expansion, then the following line (marked:&gt;&gt;&gt;&gt;) in vector.hpp computes the raw_gap as zero: </p> <blockquote> <p> <em>Old situation: </em> <span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"> <em>| raw_mem | old_begin | old_end | </em>| </span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span>_|<span class="underline"></span><span class="underline"></span><span class="underline">_|</span><span class="underline"></span><span class="underline">_| <em> </em>New situation: <em> </em></span><em><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span> </em>| old_begin | new | old_end | raw_mem | <em>|<span class="underline"></span><span class="underline"></span><span class="underline">_|</span><span class="underline"></span><span class="underline"></span>|<span class="underline"></span><span class="underline"></span>_|<span class="underline"></span><span class="underline"></span><span class="underline"></span><span class="underline"></span>_| </em> <em>Now initialize the rest of memory with the last old values </em>All new elements correctly constructed, avoid new element destruction </p> <blockquote class="citation"> <blockquote class="citation"> <blockquote class="citation"> <blockquote class="citation"> <blockquote> <p> <strong>const size_type raw_gap = s_before - before_plus_new;</strong> </p> </blockquote> </blockquote> </blockquote> </blockquote> </blockquote> <p> if(!value_traits::trivial_dctr){ </p> </blockquote> <p> This results in boost::container::move being called with the same source and destination. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11912 Trac 1.4.3 zeeshan.qazi@… Thu, 14 Jan 2016 15:27:09 GMT <link>https://svn.boost.org/trac10/ticket/11912#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11912#comment:1</guid> <description> <p> Sorry: the code block should appear as below: </p> <pre class="wiki"> //Old situation: // __________________________________________________ //| raw_mem | old_begin | old_end | //| ___________________________|___________|_________| // //New situation: // __________________________________________________ //| old_begin | new | old_end | raw_mem | //|___________|__________|_________|_________________| // //Now initialize the rest of memory with the last old values //All new elements correctly constructed, avoid new element destruction const size_type raw_gap = s_before - before_plus_new; if(!value_traits::trivial_dctr){ </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 21 Jan 2016 22:42:58 GMT</pubDate> <title>component changed; owner set https://svn.boost.org/trac10/ticket/11912#comment:2 https://svn.boost.org/trac10/ticket/11912#comment:2 <ul> <li><strong>owner</strong> set to <span class="trac-author">Ion Gaztañaga</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">interprocess</span> </li> </ul> Ticket Ion Gaztañaga Wed, 24 Feb 2016 21:32:25 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11912#comment:3 https://svn.boost.org/trac10/ticket/11912#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Many thanks for the report. Fixed in commit: </p> <p> <a class="ext-link" href="https://github.com/boostorg/container/commit/3e82a27917976e4941b8cde484a14a345ac22d58"><span class="icon">​</span>https://github.com/boostorg/container/commit/3e82a27917976e4941b8cde484a14a345ac22d58</a> </p> Ticket