This is the error that I am getting reported back to me by valgrind for
my program. Unfortunately whatever the real reason is causing Valgrind
to barf at this error and cry foul. The Valgrind FAQ says fix your
memory errors and this will hopefully go away. Well I am quite naive on
my use of Valgrind to nail down a particular bug. From the output below
can anyone suggested as to where to start looking?
System: Fedora Core 6
GCC: 4.1.1 20070105 (Red Hat 4.1.1-51)
BOOST: 1.33.1 (11.fc6)
Reverse_Impl::print_Graph is defined as:
void Reverse_Impl::print_Graph ( infrastructure::Component_Graph
const& graph_ref,
std::string const name ) const
{
std::stringstream output_data;
visitor::Graphviz_Visitor graphviz_ref ( graph_ref,
output_data );
boost::breadth_first_search
( graph_ref.get_Graph(), // Return the Boost directed graph
graph_ref.get_Vertex ( 1 ), // Return the root vertex in
the boost graph
boost::visitor ( graphviz_ref ) );
std::stringstream filename;
filename << name << ".dot";
std::string final_name = filename.str();
std::ofstream output_file ( final_name.c_str() );
output_file << "digraph " << name << " {" << std::endl;
output_file << output_data.str();
output_file << "}" << std::endl;
output_file.close();
}
Graphviz_Vistor discover_vertex is the only function I override in the
default breadth first search visitor:
class Graphviz_Visitor : public boost::default_bfs_visitor
{
public:
// Constructor
Graphviz_Visitor ( infrastructure::Component_Graph const&
graph_ref,
std::stringstream& output );
// Visitor functions
template
void discover_vertex(Vertex v, Graph const& g)
{
typename Graph::out_edge_iterator pos;
typename Graph::out_edge_iterator end;
typename Graph::vertex_descriptor node;
typename infrastructure::Component::ptr_t target_obj_ptr;
typename infrastructure::Component::ptr_t src_obj_ptr =
m_graph_ref.get_Component(v);
// Print out graphviz node for vertex
m_output_data << boost::format("%d [label=\"%s(%d)\"];")
% src_obj_ptr->get_ID()
% src_obj_ptr->get_Name()
% src_obj_ptr->get_ID()
<< std::endl;
// For all children, print out path from vertex id to child
id
for ( boost::tie(pos,end) = out_edges(v, g); pos != end;
++pos)
{
node = target (*pos, g);
target_obj_ptr = m_graph_ref.get_Component(node);
m_output_data << boost::format("%d -> %d;")
% src_obj_ptr->get_ID()
% target_obj_ptr->get_ID()
<< std::endl;
}
}
private:
infrastructure::Component_Graph const& m_graph_ref;
std::stringstream& m_output_data;
};
File_Type_Detector(1) - initialized with data from component #0
==13733== Invalid write of size 4
==13733== at 0x4155F73: void boost::putboost::default_color_type > >, boost::adj_list_vertex_property_maplibreverse::infrastructure::Component, boost::no_property> >, boost::shared_ptrlibreverse::infrastructure::Component, boost::shared_ptrlibreverse::infrastructure::Component, boost::listS>, unsigned, unsigned const&, boost::property>, boost::default_color_type, boost::default_color_type&>, unsigned const, void*, boost::default_color_type>(boost::put_get_helperboost::default_color_type > >, boost::adj_list_vertex_property_maplibreverse::infrastructure::Component, boost::no_property> >, boost::shared_ptrlibreverse::infrastructure::Component, boost::shared_ptrlibreverse::infrastructure::Component, boost::listS>, unsigned, unsigned const&, boost::property>, boost::default_color_type, boost::default_color_type&> > const&, void*, boost::default_color_type const&) (property_map.hpp:319)
==13733== by 0x415D9D1: void boost::breadth_first_searchlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, boost::queuelibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, std::allocatorlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS> > > >, libreverse::visitor::Graphviz_Visitor, boost::iterator_property_map<__gnu_cxx::__normal_iteratorlibreverse::visitor::Graphviz_Visitor > >, boost::adj_list_vertex_property_map, libreverse::visitor::Graphviz_Visitor, libreverse::visitor::Graphviz_Visitor&> >(boost::adjacency_listlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS> const&, boost::graph_traitsboost::adj_list_vertex_property_map::vertex_descriptor, boost::queuelibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, std::allocatorlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS> > > >&, libreverse::visitor::Graphviz_Visitor, boost::iterator_property_map<__gnu_cxx::__normal_iteratorlibreverse::visitor::Graphviz_Visitor > >, boost::adj_list_vertex_property_map, libreverse::visitor::Graphviz_Visitor, libreverse::visitor::Graphviz_Visitor&>) (breadth_first_search.hpp:97)
==13733== by 0x415DAF1: void boost::detail::bfs_helperlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, boost::iterator_property_map<__gnu_cxx::__normal_iterator > >, boost::adj_list_vertex_property_map, __gnu_cxx, __gnu_cxx&>, libreverse::visitor::Graphviz_Visitor, unsigned const&, boost::graph_visitor_t, boost::no_property>(boost::adjacency_listlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>&, boost::graph_traits<__gnu_cxx>::vertex_descriptor, boost::iterator_property_map<__gnu_cxx::__normal_iterator > >, boost::adj_list_vertex_property_map, __gnu_cxx, __gnu_cxx&>, libreverse::visitor::Graphviz_Visitor, boost::bgl_named_params const&) (breadth_first_search.hpp:185)
==13733== by 0x415DCC1: void boost::detail::bfs_dispatchboost::detail::error_property_not_found::applylibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, libreverse::visitor::Graphviz_Visitor, boost::graph_visitor_t, boost::no_property>(boost::adjacency_listlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>&, boost::graph_traitslibreverse::visitor::Graphviz_Visitor::vertex_descriptor, boost::bgl_named_params const&, boost::detail::error_property_not_found) (breadth_first_search.hpp:226)
==13733== by 0x415DD4B: void boost::breadth_first_searchlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, libreverse::visitor::Graphviz_Visitor, boost::graph_visitor_t, boost::no_property>(boost::adjacency_listlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS> const&, boost::graph_traitslibreverse::visitor::Graphviz_Visitor::vertex_descriptor, boost::bgl_named_params const&) (breadth_first_search.hpp:255)
==13733== by 0x41515D5: libreverse::api::Reverse_Impl::print_Graph(libreverse::infrastructure::Component_Graph const&, std::string) const (Reverse_Impl.cpp:189)
==13733== by 0x4151D71: libreverse::api::Reverse_Impl::execute_Analysis_Section(boost::shared_ptrlibreverse::infrastructure::Component_Graph, std::lessstd::string, std::allocatorlibreverse::infrastructure::Component_Graph > > > >, std::pair, boost::shared_ptrlibreverse::infrastructure::Component > const&) (Reverse_Impl.cpp:104)
==13733== by 0x4144534: libreverse::api::Reverse::execute(std::string const&, unsigned const&, unsigned const&) (Reverse.cpp:138)
==13733== by 0x8055599: main (reverse.cpp:50)
==13733== Address 0x5AE64F0 is not stack'd, malloc'd or (recently) free'd
valgrind: m_mallocfree.c:178 (mk_plain_bszB): Assertion 'bszB != 0' failed.
==13733== at 0x38016499: report_and_quit (m_libcassert.c:136)
==13733== by 0x380167C3: vgPlain_assert_fail (m_libcassert.c:200)
==13733== by 0x3802040C: vgPlain_arena_malloc (m_mallocfree.c:178)
==13733== by 0x38036077: vgPlain_cli_malloc (replacemalloc_core.c:101)
==13733== by 0x3800238E: vgMemCheck___builtin_new (mc_malloc_wrappers.c:182)
==13733== by 0x380367D2: do_client_request (scheduler.c:1158)
==13733== by 0x3803810C: vgPlain_scheduler (scheduler.c:869)
==13733== by 0x38057103: run_a_thread_NORETURN (syswrap-linux.c:87)
sched status:
running_tid=1
Thread 1: status = VgTs_Runnable
==13733== at 0x4005BA5: operator new(unsigned) (vg_replace_malloc.c:163)
==13733== by 0x48035A1A: std::string::_Rep::_S_create(unsigned, unsigned, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.8)
==13733== by 0x48037747: std::string::_M_mutate(unsigned, unsigned, unsigned) (in /usr/lib/libstdc++.so.6.0.8)
==13733== by 0x480378E9: std::string::_M_replace_safe(unsigned, unsigned, char const*, unsigned) (in /usr/lib/libstdc++.so.6.0.8)
==13733== by 0x48038959: std::string::replace(unsigned, unsigned, char const*, unsigned) (in /usr/lib/libstdc++.so.6.0.8)
==13733== by 0x48038B46: std::string::replace(__gnu_cxx::__normal_iterator, __gnu_cxx::__normal_iterator, __gnu_cxx::__normal_iterator, __gnu_cxx::__normal_iterator) (in /usr/lib/libstdc++.so.6.0.8)
==13733== by 0x8057F3D: std::string& std::string::append<__gnu_cxx::__normal_iterator >(__gnu_cxx::__normal_iterator, __gnu_cxx::__normal_iterator) (basic_string.h:847)
==13733== by 0x8057FDF: void boost::io::detail::append_stringstd::string(std::string&, std::string const&, std::string::size_type, std::string::size_type) (parsing.hpp:383)
==13733== by 0x8063049: boost::basic_format::parse(std::string const&) (parsing.hpp:433)
==13733== by 0x8063593: boost::basic_format::basic_format(char const*) (format_implementation.hpp:33)
==13733== by 0x415C2D8: void libreverse::visitor::Graphviz_Visitor::discover_vertexlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS> >(void*, boost::adjacency_listlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS> const&) (Graphviz_Visitor.h:33)
==13733== by 0x415D5E6: void boost::breadth_first_visitlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, boost::queuelibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, std::allocatorlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS> > > >, libreverse::visitor::Graphviz_Visitor, boost::iterator_property_map<__gnu_cxx::__normal_iteratorlibreverse::visitor::Graphviz_Visitor > >, boost::adj_list_vertex_property_map, libreverse::visitor::Graphviz_Visitor, libreverse::visitor::Graphviz_Visitor&> >(boost::adjacency_listlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS> const&, boost::graph_traitsboost::adj_list_vertex_property_map::vertex_descriptor, boost::queuelibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, std::allocatorlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS> > > >&, libreverse::visitor::Graphviz_Visitor, boost::iterator_property_map<__gnu_cxx::__normal_iteratorlibreverse::visitor::Graphviz_Visitor > >, boost::adj_list_vertex_property_map, libreverse::visitor::Graphviz_Visitor, libreverse::visitor::Graphviz_Visitor&>) (breadth_first_search.hpp:65)
==13733== by 0x415DA51: void boost::breadth_first_searchlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, boost::queuelibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, std::allocatorlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS> > > >, libreverse::visitor::Graphviz_Visitor, boost::iterator_property_map<__gnu_cxx::__normal_iteratorlibreverse::visitor::Graphviz_Visitor > >, boost::adj_list_vertex_property_map, libreverse::visitor::Graphviz_Visitor, libreverse::visitor::Graphviz_Visitor&> >(boost::adjacency_listlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS> const&, boost::graph_traitsboost::adj_list_vertex_property_map::vertex_descriptor, boost::queuelibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, std::allocatorlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS> > > >&, libreverse::visitor::Graphviz_Visitor, boost::iterator_property_map<__gnu_cxx::__normal_iteratorlibreverse::visitor::Graphviz_Visitor > >, boost::adj_list_vertex_property_map, libreverse::visitor::Graphviz_Visitor, libreverse::visitor::Graphviz_Visitor&>) (breadth_first_search.hpp:100)
==13733== by 0x415DAF1: void boost::detail::bfs_helperlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, boost::iterator_property_map<__gnu_cxx::__normal_iterator > >, boost::adj_list_vertex_property_map, __gnu_cxx, __gnu_cxx&>, libreverse::visitor::Graphviz_Visitor, unsigned const&, boost::graph_visitor_t, boost::no_property>(boost::adjacency_listlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>&, boost::graph_traits<__gnu_cxx>::vertex_descriptor, boost::iterator_property_map<__gnu_cxx::__normal_iterator > >, boost::adj_list_vertex_property_map, __gnu_cxx, __gnu_cxx&>, libreverse::visitor::Graphviz_Visitor, boost::bgl_named_params const&) (breadth_first_search.hpp:185)
==13733== by 0x415DCC1: void boost::detail::bfs_dispatchboost::detail::error_property_not_found::applylibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, libreverse::visitor::Graphviz_Visitor, boost::graph_visitor_t, boost::no_property>(boost::adjacency_listlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>&, boost::graph_traitslibreverse::visitor::Graphviz_Visitor::vertex_descriptor, boost::bgl_named_params const&, boost::detail::error_property_not_found) (breadth_first_search.hpp:226)
==13733== by 0x415DD4B: void boost::breadth_first_searchlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS>, libreverse::visitor::Graphviz_Visitor, boost::graph_visitor_t, boost::no_property>(boost::adjacency_listlibreverse::infrastructure::Component, boost::no_property> >, boost::no_property, boost::no_property, boost::listS> const&, boost::graph_traitslibreverse::visitor::Graphviz_Visitor::vertex_descriptor, boost::bgl_named_params const&) (breadth_first_search.hpp:255)
==13733== by 0x41515D5: libreverse::api::Reverse_Impl::print_Graph(libreverse::infrastructure::Component_Graph const&, std::string) const (Reverse_Impl.cpp:189)
==13733== by 0x4151D71: libreverse::api::Reverse_Impl::execute_Analysis_Section(boost::shared_ptrlibreverse::infrastructure::Component_Graph, std::lessstd::string, std::allocatorlibreverse::infrastructure::Component_Graph > > > >, std::pair, boost::shared_ptrlibreverse::infrastructure::Component > const&) (Reverse_Impl.cpp:104)
==13733== by 0x4144534: libreverse::api::Reverse::execute(std::string const&, unsigned const&, unsigned const&) (Reverse.cpp:138)
==13733== by 0x8055599: main (reverse.cpp:50)
Stephen