Boost C++ Libraries: Ticket #5251: boost graph seg faults inside gdb https://svn.boost.org/trac10/ticket/5251 <p> I have a class with a boost graph member variable in it. </p> <p> When I call a method from within gdb, to get the number of edges of a graph, I get a segmentation fault. </p> <p> I'm attaching a standalone code that reproduces it: </p> <ol><li>Enter GDB </li><li>Set a breakpoint on line number 34 </li><li>From within GDB execute the following: (a) p wrapper.dummy_.nedges() (b) p dummy.nedges() </li></ol><p> 3a is fine, prints out 0 as it should be. The graph is empty. </p> <p> 3b seg faults though... </p> <p> This is the resulting call stack: </p> <p> <a class="missing ticket">#0</a> 0x08049b90 in std::_List_const_iterator&lt;boost::list_edge&lt;void*, boost::property&lt;boost::edge_bundle_t, int, boost::no_property&gt; &gt; &gt;::operator++ (this=0xbffff6fc) at /usr/include/c++/4.4/bits/stl_list.h:223 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1" title="#1: Bugs: boost.build causes ftjam to segfault (closed: Wont Fix)">#1</a> 0x08049427 in std::<span class="underline">distance&lt;std::_List_const_iterator&lt;boost::list_edge&lt;void*, boost::property&lt;boost::edge_bundle_t, int, boost::no_property&gt; &gt; &gt; &gt; (</span>first=..., <span class="underline">last=...) at /usr/include/c++/4.4/bits/stl_iterator_base_funcs.h:79 </span></p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2" title="#2: Bugs: list::size should be const (closed: fixed)">#2</a> 0x08048ea3 in std::distance&lt;std::_List_const_iterator&lt;boost::list_edge&lt;void*, boost::property&lt;boost::edge_bundle_t, int, boost::no_property&gt; &gt; &gt; &gt; (<span class="underline">first=..., </span>last=...) at /usr/include/c++/4.4/bits/stl_iterator_base_funcs.h:114 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3" title="#3: Bugs: automatic conversion and overload proble (closed: fixed)">#3</a> 0x08048c12 in std::list&lt;boost::list_edge&lt;void*, boost::property&lt;boost::edge_bundle_t, int, boost::no_property&gt; &gt;, std::allocator&lt;boost::list_edge&lt;void*, boost::property&lt;boost::edge_bundle_t, int, boost::no_property&gt; &gt; &gt; &gt;::size (this=0xbffff7c4) at /usr/include/c++/4.4/bits/stl_list.h:805 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4" title="#4: Bugs: any_ptr in any library documentation? (closed: Fixed)">#4</a> 0x08048a3a in boost::num_edges&lt;boost::detail::adj_list_gen&lt;boost::adjacency_list&lt;boost::listS, boost::listS, boost::undirectedS, int, int, boost::no_property, boost::listS&gt;, boost::listS, boost::listS, boost::undirectedS, boost::property&lt;boost::vertex_bundle_t, int, boost::no_property&gt;, boost::property&lt;boost::edge_bundle_t, int, boost::no_property&gt;, boost::no_property, boost::listS&gt;::config&gt; (g_=...) at /usr/include/boost/graph/detail/adjacency_list.hpp:978 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5" title="#5: Bugs: shared_ptr and self-owning objects (closed: Fixed)">#5</a> 0x08048865 in dummy_class::nedges (this=0xbffff7c4) at graph.cxx:17 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6" title="#6: Bugs: tie in utility.hpp and tuple.hpp clash. (closed: Duplicate)">#6</a> &lt;function called from gdb&gt; </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7" title="#7: Bugs: g++ 2.96 requires NO_STRINGSTREAM (closed: Fixed)">#7</a> dummy_method () at graph.cxx:34 </p> <p> <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/8" title="#8: Bugs: prop in undirected graph + out_edges (closed: Works For Me)">#8</a> 0x080488ea in main (argc=3, argv=0xbffff914) at graph.cxx:43 </p> <p> This is preventing us from using the graph reliably. </p> <p> Using Ubuntu 10.10 with Boost 1.42.0 and G++ 4.4.4. </p> <p> Reproduceable on Ubuntu 9.10 as well. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5251 Trac 1.4.3 joao@… Tue, 01 Mar 2011 15:38:00 GMT attachment set https://svn.boost.org/trac10/ticket/5251 https://svn.boost.org/trac10/ticket/5251 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">graph.2.cxx</span> </li> </ul> <p> sample code to reproduce the bug </p> Ticket Jeremiah Willcock Tue, 01 Mar 2011 18:15:48 GMT <link>https://svn.boost.org/trac10/ticket/5251#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5251#comment:1</guid> <description> <p> Does this problem happen outside the debugger? Also, could you please try compiling with <code>-D_GLIBCXX_DEBUG</code> and see if that changes the behavior at all? </p> </description> <category>Ticket</category> </item> <item> <author>jalrnc@…</author> <pubDate>Tue, 01 Mar 2011 22:12:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/5251#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5251#comment:2</guid> <description> <p> Yes, I've seen it crash outside the debugger before, when printing the number of edges. Even though I cannot make it happen with that specific sample of code. </p> <p> Your suggestion does not change the behavior. </p> <p> Here is a piece of info that may provide some clue. I'm using g++ 4.4 for the above. This generates a few warnings concerning deprecated interfaces in boost. That may be related to the problem. I tried using g++ 4.2 and it all works fine. With g++ 4.2 all the compilation warnings related to deprecated interfaces in boost are gone as well. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Wed, 02 Mar 2011 19:48:23 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5251#comment:3 https://svn.boost.org/trac10/ticket/5251#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">wontfix</span> </li> </ul> <p> I tried it using GCC 4.1.2, and it also fails; it works using GCC 3.4.6 and GCC 4.6.0 20101120 (you can't print <code>dummy.nedges()</code>, but <code>dummy</code> is reasonable). The list of edges in <code>dummy</code> ends up being circular, leading to an infinite loop. Printing out the two values listed in the bug report within the program works fine (both returning 0), but it does loop in the debugger. I'm not sure what I can do about the problem, though; it is unlikely to be a BGL problem when everything works in the code and passes valgrind and <code>_GLIBCXX_DEBUG</code>. I'm going to close it as "wontfix" since I suspect it's not a BGL issue, even though I can reproduce it myself. </p> Ticket Jeremiah Willcock Wed, 02 Mar 2011 20:11:53 GMT <link>https://svn.boost.org/trac10/ticket/5251#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5251#comment:4</guid> <description> <p> The code also works in GCC 4.5.0. </p> </description> <category>Ticket</category> </item> </channel> </rss>