Boost logo

Boost :

From: Heiko Bauke (heiko.bauke_at_[hidden])
Date: 2007-02-08 08:26:38


since a day I was fighting with a strange bug in my program. Finally, I
think, I could trace down this error to a problem in the Boost graph
library. The following test program crashes, in a call to

#include <cstdlib>
#include <boost/tuple/tuple.hpp>
#include <boost/graph/adjacency_list.hpp>

typedef boost::adjacency_list<boost::vecS, boost::vecS,
boost::undirectedS> graph_t; typedef
boost::graph_traits<graph_t>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<graph_t>::vertex_iterator vertex_iterator;

int main() {
  graph_t G(8);
  vertex_iterator vi, vi_end, ui, ui_end;
  for (boost::tie(vi, vi_end)=boost::vertices(G); vi!=vi_end; ++vi)
    for (boost::tie(ui, ui_end)=boost::vertices(G); ui!=ui_end; ++ui)
      // if (*vi!=*ui)
      boost::add_edge(*vi, *ui, G);
  for (boost::tie(vi, vi_end)=boost::vertices(G); vi!=vi_end; ++vi)
    boost::clear_vertex(*vi, G);
  return EXIT_SUCCESS;

It seams to me, there is a double free error, that occurs if the
adjacency_list has self-loops. If the if-statement is not commented
out, the program does not crash. I am using Boost 1.33.1.


-- Perfection is attained not when there is nothing more to add, but 
-- when there is nothing more to remove.  (Antoine de Saint-Exupéry)
-- Cluster Computing @
--       Heiko Bauke @

Boost list run by bdawes at, gregod at, cpdaniel at, john at