Boost C++ Libraries: Ticket #10987: bug in any_xxx_node_traits, returning by reference https://svn.boost.org/trac10/ticket/10987 <p> bstree_algo::rotate_left has parameter p_parent passed by const ref (invoked by rebalance_after_insertion). </p> <p> With set hook this is ref to temporary variable (default_rbtree_node_traits_impl::get_parent returns value). </p> <p> With any hook this is ref to node's variable (any_rbtree_node_traits::get_parent returns reference). </p> <p> This variable is used after node changed. Use local var? </p> <p> PS: are other rotate_XXX functions OK? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10987 Trac 1.4.3 anonymous Sun, 01 Feb 2015 01:56:10 GMT <link>https://svn.boost.org/trac10/ticket/10987#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10987#comment:1</guid> <description> <p> After fixing this I still have infinite loops and crashes in intrusive sets. Rolled back to 1.55 where everything is stable for me... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Sun, 01 Feb 2015 18:20:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10987#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10987#comment:2</guid> <description> <p> I can't see any problem with the code, the temporary is valid until the function ends. Any chance to have a test program that reproduces your crash? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sun, 01 Feb 2015 21:51:18 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/10987 https://svn.boost.org/trac10/ticket/10987 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">ConsoleApplication1.cpp</span> </li> </ul> Ticket anonymous Sun, 01 Feb 2015 21:56:53 GMT <link>https://svn.boost.org/trac10/ticket/10987#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10987#comment:3</guid> <description> <p> Yes, memory block is valid. But this is not temporary, this is any hook's member. In case of non-any hook (normal set_base_hook) this IS actually a temporary. </p> <p> Program above can be fixed by making parameter p_parent not ref but value. But there are more bugs and I currently not able to find out, ma application still crashing or has infinite loops but only after some time. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sun, 01 Feb 2015 22:10:22 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10987#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10987#comment:4</guid> <description> <p> To be even more specific: &amp;p_parent == &amp;p.node_ptr_1 in case of any_hook. So when rotate_left calls rotate_left_no_parent_fix(p,...) &amp;p_parent starts p_right, while with set_base_hook it remains the same. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Mon, 02 Feb 2015 16:27:19 GMT</pubDate> <title>status, summary changed; resolution set https://svn.boost.org/trac10/ticket/10987#comment:5 https://svn.boost.org/trac10/ticket/10987#comment:5 <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> <li><strong>summary</strong> <span class="trac-field-old">bstree_algo::rotate_left bug</span> → <span class="trac-field-new">bug in any_xxx_node_traits, returning by reference</span> </li> </ul> <p> Ok, I see. The problem is in the any hook member, it should not return by reference. This was changed in all other node_traits and it seems I forgot to do the same with any_xxx_node_traits classes. </p> <p> Fixed in: </p> <p> <a class="ext-link" href="https://github.com/boostorg/intrusive/commit/b9aa032d981ad65fce5ea99179e22c25e35f03e8"><span class="icon">​</span>https://github.com/boostorg/intrusive/commit/b9aa032d981ad65fce5ea99179e22c25e35f03e8</a> </p> <p> Thanks for the report. </p> Ticket anonymous Mon, 02 Feb 2015 22:22:03 GMT <link>https://svn.boost.org/trac10/ticket/10987#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10987#comment:6</guid> <description> <p> Happy to help! </p> <p> PS: TBH strange function argument requirement to be temporary, at least static assertion in rbtree_algorithms could verify that hook trait returns value. </p> </description> <category>Ticket</category> </item> </channel> </rss>