Boost C++ Libraries: Ticket #4622: clear_vertex on a vertex with a self-loop can cause a segmentation fault https://svn.boost.org/trac10/ticket/4622 <p> Attached is a minimal test case that raises a segmentation fault. When line 23, <code>add_edge(5, 5, g);</code>, is commented out, then the fault no longer occurs. </p> <p> I am currently at trunk revision 65192. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4622 Trac 1.4.3 dtrebbien@… Thu, 02 Sep 2010 15:25:05 GMT attachment set https://svn.boost.org/trac10/ticket/4622 https://svn.boost.org/trac10/ticket/4622 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">clear_vertex_min_test.cpp</span> </li> </ul> Ticket Jeremiah Willcock Thu, 02 Sep 2010 18:24:21 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4622#comment:1 https://svn.boost.org/trac10/ticket/4622#comment:1 <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> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/65198" title="Fixed clearing of vertices with self-loop edges; fixes #4622">[65198]</a>) Fixed clearing of vertices with self-loop edges; fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4622" title="#4622: Bugs: clear_vertex on a vertex with a self-loop can cause a segmentation fault (closed: fixed)">#4622</a> </p> Ticket Phil Endecott Thu, 10 May 2012 22:20:16 GMT <link>https://svn.boost.org/trac10/ticket/4622#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4622#comment:2</guid> <description> <p> The fixed version still seems wrong. Consider a vertex in an undirected graph with only self-loops. The current code will do nothing inside the loop, and then clear the out_edge_list. The problem is that m_edges has not been updated to remove these edges. When I subsequently iterate over all the edges in the graph, I still find these edges (and then crash). </p> <p> This is the first time that I've ever used Boost.Graph so it's possible that I'm misunderstanding something... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 11 May 2012 14:36:13 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/4622#comment:3 https://svn.boost.org/trac10/ticket/4622#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> Ticket Jeremiah Willcock Fri, 11 May 2012 19:37:57 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4622#comment:4 https://svn.boost.org/trac10/ticket/4622#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/78425" title="Fixed handling of self-loops; fixes #4622">[78425]</a>) Fixed handling of self-loops; fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4622" title="#4622: Bugs: clear_vertex on a vertex with a self-loop can cause a segmentation fault (closed: fixed)">#4622</a> </p> Ticket anonymous Fri, 11 May 2012 20:54:32 GMT <link>https://svn.boost.org/trac10/ticket/4622#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4622#comment:5</guid> <description> <p> Have you tested that? </p> <p> It looks to me as if it will now try to erase the same element from m_edges twice. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Fri, 11 May 2012 21:03:22 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4622#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4622#comment:6</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/78428" title="Trying to fix undirected clear_vertex() again; refs #4622">[78428]</a>) Trying to fix undirected clear_vertex() again; refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4622" title="#4622: Bugs: clear_vertex on a vertex with a self-loop can cause a segmentation fault (closed: fixed)">#4622</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sat, 12 May 2012 13:48:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4622#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4622#comment:7</guid> <description> <p> Please try to convince me that the new code is correct. It's not obvious to me why it would now call m_edges.erase() only once per self-loop edge. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Sat, 12 May 2012 18:51:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4622#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4622#comment:8</guid> <description> <p> As long as each self-loop appears in the out-edge list exactly once, it will be deleted exactly once since that is what the loop that deletes from <code>m_edges</code> does (and the loop doesn't do anything else anymore). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sat, 12 May 2012 19:27:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4622#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4622#comment:9</guid> <description> <p> I thought that each self-loop appeared twice in the out-edge list, for an undirected graph. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Sat, 12 May 2012 20:10:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4622#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4622#comment:10</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/78439" title="Fixed bugs in remove_edge and clear_vertex for undirected graphs; refs ...">[78439]</a>) Fixed bugs in remove_edge and clear_vertex for undirected graphs; refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4622" title="#4622: Bugs: clear_vertex on a vertex with a self-loop can cause a segmentation fault (closed: fixed)">#4622</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sat, 12 May 2012 22:14:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4622#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4622#comment:11</guid> <description> <p> It would be great to get some sort of explanation either here or in the commit message. </p> <p> Do you believe that the old remove_edge was also wrong, or was that change needed only because of how you have now implemented clear_vertex? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Sat, 12 May 2012 22:40:32 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4622#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4622#comment:12</guid> <description> <p> The old <code>remove_edge</code> was wrong in general; compiling <code>libs/graph/test/graph.cpp</code> with <code>-D_GLIBCXX_DEBUG</code> and adding in some self-loops led to dereferencing of singular iterators before <code>clear_vertex</code> was called at all. The patch to <code>clear_vertex</code> is a rewrite changing it to a brute-force version ("while any adjacent edges exist, remove the first one"). </p> </description> <category>Ticket</category> </item> <item> <author>i@…</author> <pubDate>Fri, 21 Jun 2013 12:10:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4622#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4622#comment:13</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/4622#comment:10" title="Comment 10">jewillco</a>: </p> <blockquote class="citation"> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/78439" title="Fixed bugs in remove_edge and clear_vertex for undirected graphs; refs ...">[78439]</a>) Fixed bugs in remove_edge and clear_vertex for undirected graphs; refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4622" title="#4622: Bugs: clear_vertex on a vertex with a self-loop can cause a segmentation fault (closed: fixed)">#4622</a> </p> </blockquote> <p> This introduced a regression for me. What is the added BOOST_ASSERT in remove_edge_and_property good for? Especially considering the condition right after it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Fri, 21 Jun 2013 20:06:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4622#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4622#comment:14</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/84869" title="Removed assertion to enable removal of non-existent edges, as ...">[84869]</a>) Removed assertion to enable removal of non-existent edges, as suggested by comment to <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4622" title="#4622: Bugs: clear_vertex on a vertex with a self-loop can cause a segmentation fault (closed: fixed)">#4622</a>; refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4622" title="#4622: Bugs: clear_vertex on a vertex with a self-loop can cause a segmentation fault (closed: fixed)">#4622</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>