|
From: Stephen T. <st...@to...> - 2007-03-31 00:09:30
|
> My (buggy) program dies like this: > % valgrind: vg_malloc2.c:442 (bszW_to_pszW): Assertion 'pszW >=3D 0' fail= ed. >=20 > If Memcheck (the memory checker) shows any invalid reads, invalid > writes and invalid frees in your program, the above may happen. Reason > is that your program may trash Valgrind's low-level memory manager, > which then dies with the above assertion, or something like this. The > cure is to fix your program so that it doesn't do any illegal memory > accesses. The above failure will hopefully go away after that. The above is a quotation from the Valgrind FAQ. Without sounding sarcastic the answer is not that helpful. The point that I am using Valgrind is to find the illegal memory accesses. I started my program with the following flags when I got a similar assertion: valgrind -v --tool=3Dmemcheck --leak-resolution=3Dhigh ./reverse --file kernel32.dll=20 What flags should I be using or is there another tool in valgrind I should be using instead of memcheck? I do not have a strong skill using Valgrind to find errors. So any help would be appreciated. Stephen ------- FULL ERROR --------- =3D=3D13733=3D=3D Invalid write of size 4 =3D=3D13733=3D=3D at 0x4155F73: void boost::put<boost::iterator_property= _map<__gnu_cxx::__normal_iterator<boost::default_color_type*, std::vector<b= oost::default_color_type, std::allocator<boost::default_color_type> > >, bo= ost::adj_list_vertex_property_map<boost::adjacency_list<boost::setS, boost:= :setS, boost::directedS, boost::property<boost::vertex_index_t, unsigned, b= oost::directedS<boost::vertex_name_t, boost::shared_ptr<libreverse::infrast= ructure::Component>, boost::no_property> >, boost::shared_ptr<libreverse::i= nfrastructure::Component>, boost::shared_ptr<libreverse::infrastructure::Co= mponent>, boost::listS>, unsigned, unsigned const&, boost::property>, boost= ::default_color_type, boost::default_color_type&>, unsigned const, void*, b= oost::default_color_type>(boost::put_get_helper<unsigned const, boost::iter= ator_property_map<__gnu_cxx::__normal_iterator<boost::default_color_type*, = std::vector<boost::default_color_type, std::allocator<boost::default_color_= type> > >, boost::adj_list_vertex_property_map<boost::adjacency_list<boost:= :setS, boost::setS, boost::directedS, boost::property<boost::vertex_index_t= , unsigned, boost::directedS<boost::vertex_name_t, boost::shared_ptr<librev= erse::infrastructure::Component>, boost::no_property> >, boost::shared_ptr<= libreverse::infrastructure::Component>, boost::shared_ptr<libreverse::infra= structure::Component>, boost::listS>, unsigned, unsigned const&, boost::pro= perty>, boost::default_color_type, boost::default_color_type&> > const&, vo= id*, boost::default_color_type const&) (property_map.hpp:319) =3D=3D13733=3D=3D by 0x415D9D1: void boost::breadth_first_search<boost::= adjacency_list<boost::setS, boost::setS, boost::directedS, boost::property<= boost::vertex_index_t, unsigned, boost::property<boost::vertex_name_t, boos= t::shared_ptr<libreverse::infrastructure::Component>, boost::no_property> >= , boost::no_property, boost::no_property, boost::listS>, boost::queue<void*= , std::deque<boost::adjacency_list<boost::setS, boost::setS, boost::directe= dS, boost::property<boost::vertex_index_t, unsigned, boost::property<boost:= :vertex_name_t, boost::shared_ptr<libreverse::infrastructure::Component>, b= oost::no_property> >, boost::no_property, boost::no_property, boost::listS>= , std::allocator<boost::adjacency_list<boost::setS, boost::setS, boost::dir= ectedS, boost::property<boost::vertex_index_t, unsigned, boost::property<bo= ost::vertex_name_t, boost::shared_ptr<libreverse::infrastructure::Component= >, boost::no_property> >, boost::no_property, boost::no_property, boost::li= stS> > > >, libreverse::visitor::Graphviz_Visitor, boost::iterator_property= _map<__gnu_cxx::__normal_iterator<boost::default_color_type*, std::vector<l= ibreverse::visitor::Graphviz_Visitor, std::allocator<libreverse::visitor::G= raphviz_Visitor> > >, boost::adj_list_vertex_property_map<boost::no_propert= y, unsigned, unsigned const&, boost::vertex_index_t>, libreverse::visitor::= Graphviz_Visitor, libreverse::visitor::Graphviz_Visitor&> >(boost::adjacenc= y_list<boost::setS, boost::setS, boost::directedS, boost::property<boost::v= ertex_index_t, unsigned, boost::property<boost::vertex_name_t, boost::share= d_ptr<libreverse::infrastructure::Component>, boost::no_property> >, boost:= :no_property, boost::no_property, boost::listS> const&, boost::graph_traits= <boost::adj_list_vertex_property_map>::vertex_descriptor, boost::queue<void= *, std::deque<boost::adjacency_list<boost::setS, boost::setS, boost::direct= edS, boost::property<boost::vertex_index_t, unsigned, boost::property<boost= ::vertex_name_t, boost::shared_ptr<libreverse::infrastructure::Component>, = boost::no_property> >, boost::no_property, boost::no_property, boost::listS= >, std::allocator<boost::adjacency_list<boost::setS, boost::setS, boost::di= rectedS, boost::property<boost::vertex_index_t, unsigned, boost::property<b= oost::vertex_name_t, boost::shared_ptr<libreverse::infrastructure::Componen= t>, boost::no_property> >, boost::no_property, boost::no_property, boost::l= istS> > > >&, libreverse::visitor::Graphviz_Visitor, boost::iterator_proper= ty_map<__gnu_cxx::__normal_iterator<boost::default_color_type*, std::vector= <libreverse::visitor::Graphviz_Visitor, std::allocator<libreverse::visitor:= :Graphviz_Visitor> > >, boost::adj_list_vertex_property_map<boost::no_prope= rty, unsigned, unsigned const&, boost::vertex_index_t>, libreverse::visitor= ::Graphviz_Visitor, libreverse::visitor::Graphviz_Visitor&>) (breadth_first= _search.hpp:97) =3D=3D13733=3D=3D by 0x415DAF1: void boost::detail::bfs_helper<boost::ad= jacency_list<boost::setS, boost::setS, boost::directedS, boost::property<bo= ost::vertex_index_t, unsigned, boost::property<boost::vertex_name_t, boost:= :shared_ptr<libreverse::infrastructure::Component>, boost::no_property> >, = boost::no_property, boost::no_property, boost::listS>, boost::iterator_prop= erty_map<__gnu_cxx::__normal_iterator<boost::default_color_type*, std::vect= or<__gnu_cxx, std::allocator<__gnu_cxx> > >, boost::adj_list_vertex_propert= y_map<boost::no_property, unsigned, unsigned const&, boost::vertex_index_t>= , __gnu_cxx, __gnu_cxx&>, libreverse::visitor::Graphviz_Visitor, unsigned c= onst&, boost::graph_visitor_t, boost::no_property>(boost::adjacency_list<bo= ost::setS, boost::setS, boost::directedS, boost::property<boost::vertex_ind= ex_t, unsigned, boost::property<boost::vertex_name_t, boost::shared_ptr<lib= reverse::infrastructure::Component>, boost::no_property> >, boost::no_prope= rty, boost::no_property, boost::listS>&, boost::graph_traits<__gnu_cxx>::ve= rtex_descriptor, boost::iterator_property_map<__gnu_cxx::__normal_iterator<= boost::default_color_type*, std::vector<__gnu_cxx, std::allocator<__gnu_cxx= > > >, boost::adj_list_vertex_property_map<boost::no_property, unsigned, un= signed const&, boost::vertex_index_t>, __gnu_cxx, __gnu_cxx&>, libreverse::= visitor::Graphviz_Visitor, boost::bgl_named_params<unsigned const&, boost::= graph_visitor_t, boost::no_property> const&) (breadth_first_search.hpp:185) =3D=3D13733=3D=3D by 0x415DCC1: void boost::detail::bfs_dispatch<boost::= detail::error_property_not_found>::apply<boost::adjacency_list<boost::setS,= boost::setS, boost::directedS, boost::property<boost::vertex_index_t, unsi= gned, boost::property<boost::vertex_name_t, boost::shared_ptr<libreverse::i= nfrastructure::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_list<boost::setS, bo= ost::setS, boost::directedS, boost::property<boost::vertex_index_t, unsigne= d, boost::property<boost::vertex_name_t, boost::shared_ptr<libreverse::infr= astructure::Component>, boost::no_property> >, boost::no_property, boost::n= o_property, boost::listS>&, boost::graph_traits<libreverse::visitor::Graphv= iz_Visitor>::vertex_descriptor, boost::bgl_named_params<libreverse::visitor= ::Graphviz_Visitor, boost::graph_visitor_t, boost::no_property> const&, boo= st::detail::error_property_not_found) (breadth_first_search.hpp:226) =3D=3D13733=3D=3D by 0x415DD4B: void boost::breadth_first_search<boost::= adjacency_list<boost::setS, boost::setS, boost::directedS, boost::property<= boost::vertex_index_t, unsigned, boost::property<boost::vertex_name_t, boos= t::shared_ptr<libreverse::infrastructure::Component>, boost::no_property> >= , boost::no_property, boost::no_property, boost::listS>, libreverse::visito= r::Graphviz_Visitor, boost::graph_visitor_t, boost::no_property>(boost::adj= acency_list<boost::setS, boost::setS, boost::directedS, boost::property<boo= st::vertex_index_t, unsigned, boost::property<boost::vertex_name_t, boost::= shared_ptr<libreverse::infrastructure::Component>, boost::no_property> >, b= oost::no_property, boost::no_property, boost::listS> const&, boost::graph_t= raits<libreverse::visitor::Graphviz_Visitor>::vertex_descriptor, boost::bgl= _named_params<libreverse::visitor::Graphviz_Visitor, boost::graph_visitor_t= , boost::no_property> const&) (breadth_first_search.hpp:255) =3D=3D13733=3D=3D by 0x41515D5: libreverse::api::Reverse_Impl::print_Gra= ph(libreverse::infrastructure::Component_Graph const&, std::string) const (= Reverse_Impl.cpp:189) =3D=3D13733=3D=3D by 0x4151D71: libreverse::api::Reverse_Impl::execute_A= nalysis_Section(boost::shared_ptr<std::map<std::string, boost::shared_ptr<l= ibreverse::infrastructure::Component_Graph>, std::less<std::string>, std::a= llocator<std::pair<std::string const, boost::shared_ptr<libreverse::infrast= ructure::Component_Graph> > > > >, std::pair<boost::shared_ptr<libreverse::= infrastructure::Data_Source_Base const>, boost::shared_ptr<libreverse::infr= astructure::Component> > const&) (Reverse_Impl.cpp:104) =3D=3D13733=3D=3D by 0x4144534: libreverse::api::Reverse::execute(std::s= tring const&, unsigned const&, unsigned const&) (Reverse.cpp:138) =3D=3D13733=3D=3D by 0x8055599: main (reverse.cpp:50) =3D=3D13733=3D=3D Address 0x5AE64F0 is not stack'd, malloc'd or (recently)= free'd valgrind: m_mallocfree.c:178 (mk_plain_bszB): Assertion 'bszB !=3D 0' faile= d. =3D=3D13733=3D=3D at 0x38016499: report_and_quit (m_libcassert.c:136) =3D=3D13733=3D=3D by 0x380167C3: vgPlain_assert_fail (m_libcassert.c:200= ) =3D=3D13733=3D=3D by 0x3802040C: vgPlain_arena_malloc (m_mallocfree.c:17= 8) =3D=3D13733=3D=3D by 0x38036077: vgPlain_cli_malloc (replacemalloc_core.= c:101) =3D=3D13733=3D=3D by 0x3800238E: vgMemCheck___builtin_new (mc_malloc_wra= ppers.c:182) =3D=3D13733=3D=3D by 0x380367D2: do_client_request (scheduler.c:1158) =3D=3D13733=3D=3D by 0x3803810C: vgPlain_scheduler (scheduler.c:869) =3D=3D13733=3D=3D by 0x38057103: run_a_thread_NORETURN (syswrap-linux.c:= 87) sched status: running_tid=3D1 Thread 1: status =3D VgTs_Runnable =3D=3D13733=3D=3D at 0x4005BA5: operator new(unsigned) (vg_replace_mallo= c.c:163) =3D=3D13733=3D=3D by 0x48035A1A: std::string::_Rep::_S_create(unsigned, = unsigned, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.8) =3D=3D13733=3D=3D by 0x48037747: std::string::_M_mutate(unsigned, unsign= ed, unsigned) (in /usr/lib/libstdc++.so.6.0.8) =3D=3D13733=3D=3D by 0x480378E9: std::string::_M_replace_safe(unsigned, = unsigned, char const*, unsigned) (in /usr/lib/libstdc++.so.6.0.8) =3D=3D13733=3D=3D by 0x48038959: std::string::replace(unsigned, unsigned= , char const*, unsigned) (in /usr/lib/libstdc++.so.6.0.8) =3D=3D13733=3D=3D by 0x48038B46: std::string::replace(__gnu_cxx::__norma= l_iterator<char*, std::string>, __gnu_cxx::__normal_iterator<char*, std::st= ring>, __gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::_= _normal_iterator<char const*, std::string>) (in /usr/lib/libstdc++.so.6.0.8= ) =3D=3D13733=3D=3D by 0x8057F3D: std::string& std::string::append<__gnu_c= xx::__normal_iterator<char const*, std::string> >(__gnu_cxx::__normal_itera= tor<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, st= d::string>) (basic_string.h:847) =3D=3D13733=3D=3D by 0x8057FDF: void boost::io::detail::append_string<st= d::string>(std::string&, std::string const&, std::string::size_type, std::s= tring::size_type) (parsing.hpp:383) =3D=3D13733=3D=3D by 0x8063049: boost::basic_format<char, std::char_trai= ts<char>, std::allocator<char> >::parse(std::string const&) (parsing.hpp:43= 3) =3D=3D13733=3D=3D by 0x8063593: boost::basic_format<char, std::char_trai= ts<char>, std::allocator<char> >::basic_format(char const*) (format_impleme= ntation.hpp:33) =3D=3D13733=3D=3D by 0x415C2D8: void libreverse::visitor::Graphviz_Visit= or::discover_vertex<void*, boost::adjacency_list<boost::setS, boost::setS, = boost::directedS, boost::property<boost::vertex_index_t, unsigned, boost::p= roperty<boost::vertex_name_t, boost::shared_ptr<libreverse::infrastructure:= :Component>, boost::no_property> >, boost::no_property, boost::no_property,= boost::listS> >(void*, boost::adjacency_list<boost::setS, boost::setS, boo= st::directedS, boost::property<boost::vertex_index_t, unsigned, boost::prop= erty<boost::vertex_name_t, boost::shared_ptr<libreverse::infrastructure::Co= mponent>, boost::no_property> >, boost::no_property, boost::no_property, bo= ost::listS> const&) (Graphviz_Visitor.h:33) =3D=3D13733=3D=3D by 0x415D5E6: void boost::breadth_first_visit<boost::a= djacency_list<boost::setS, boost::setS, boost::directedS, boost::property<b= oost::vertex_index_t, unsigned, boost::property<boost::vertex_name_t, boost= ::shared_ptr<libreverse::infrastructure::Component>, boost::no_property> >,= boost::no_property, boost::no_property, boost::listS>, boost::queue<void*,= std::deque<boost::adjacency_list<boost::setS, boost::setS, boost::directed= S, boost::property<boost::vertex_index_t, unsigned, boost::property<boost::= vertex_name_t, boost::shared_ptr<libreverse::infrastructure::Component>, bo= ost::no_property> >, boost::no_property, boost::no_property, boost::listS>,= std::allocator<boost::adjacency_list<boost::setS, boost::setS, boost::dire= ctedS, boost::property<boost::vertex_index_t, unsigned, boost::property<boo= st::vertex_name_t, boost::shared_ptr<libreverse::infrastructure::Component>= , boost::no_property> >, boost::no_property, boost::no_property, boost::lis= tS> > > >, libreverse::visitor::Graphviz_Visitor, boost::iterator_property_= map<__gnu_cxx::__normal_iterator<boost::default_color_type*, std::vector<li= breverse::visitor::Graphviz_Visitor, std::allocator<libreverse::visitor::Gr= aphviz_Visitor> > >, boost::adj_list_vertex_property_map<boost::no_property= , unsigned, unsigned const&, boost::vertex_index_t>, libreverse::visitor::G= raphviz_Visitor, libreverse::visitor::Graphviz_Visitor&> >(boost::adjacency= _list<boost::setS, boost::setS, boost::directedS, boost::property<boost::ve= rtex_index_t, unsigned, boost::property<boost::vertex_name_t, boost::shared= _ptr<libreverse::infrastructure::Component>, boost::no_property> >, boost::= no_property, boost::no_property, boost::listS> const&, boost::graph_traits<= boost::adj_list_vertex_property_map>::vertex_descriptor, boost::queue<void*= , std::deque<boost::adjacency_list<boost::setS, boost::setS, boost::directe= dS, boost::property<boost::vertex_index_t, unsigned, boost::property<boost:= :vertex_name_t, boost::shared_ptr<libreverse::infrastructure::Component>, b= oost::no_property> >, boost::no_property, boost::no_property, boost::listS>= , std::allocator<boost::adjacency_list<boost::setS, boost::setS, boost::dir= ectedS, boost::property<boost::vertex_index_t, unsigned, boost::property<bo= ost::vertex_name_t, boost::shared_ptr<libreverse::infrastructure::Component= >, boost::no_property> >, boost::no_property, boost::no_property, boost::li= stS> > > >&, libreverse::visitor::Graphviz_Visitor, boost::iterator_propert= y_map<__gnu_cxx::__normal_iterator<boost::default_color_type*, std::vector<= libreverse::visitor::Graphviz_Visitor, std::allocator<libreverse::visitor::= Graphviz_Visitor> > >, boost::adj_list_vertex_property_map<boost::no_proper= ty, unsigned, unsigned const&, boost::vertex_index_t>, libreverse::visitor:= :Graphviz_Visitor, libreverse::visitor::Graphviz_Visitor&>) (breadth_first_= search.hpp:65) =3D=3D13733=3D=3D by 0x415DA51: void boost::breadth_first_search<boost::= adjacency_list<boost::setS, boost::setS, boost::directedS, boost::property<= boost::vertex_index_t, unsigned, boost::property<boost::vertex_name_t, boos= t::shared_ptr<libreverse::infrastructure::Component>, boost::no_property> >= , boost::no_property, boost::no_property, boost::listS>, boost::queue<void*= , std::deque<boost::adjacency_list<boost::setS, boost::setS, boost::directe= dS, boost::property<boost::vertex_index_t, unsigned, boost::property<boost:= :vertex_name_t, boost::shared_ptr<libreverse::infrastructure::Component>, b= oost::no_property> >, boost::no_property, boost::no_property, boost::listS>= , std::allocator<boost::adjacency_list<boost::setS, boost::setS, boost::dir= ectedS, boost::property<boost::vertex_index_t, unsigned, boost::property<bo= ost::vertex_name_t, boost::shared_ptr<libreverse::infrastructure::Component= >, boost::no_property> >, boost::no_property, boost::no_property, boost::li= stS> > > >, libreverse::visitor::Graphviz_Visitor, boost::iterator_property= _map<__gnu_cxx::__normal_iterator<boost::default_color_type*, std::vector<l= ibreverse::visitor::Graphviz_Visitor, std::allocator<libreverse::visitor::G= raphviz_Visitor> > >, boost::adj_list_vertex_property_map<boost::no_propert= y, unsigned, unsigned const&, boost::vertex_index_t>, libreverse::visitor::= Graphviz_Visitor, libreverse::visitor::Graphviz_Visitor&> >(boost::adjacenc= y_list<boost::setS, boost::setS, boost::directedS, boost::property<boost::v= ertex_index_t, unsigned, boost::property<boost::vertex_name_t, boost::share= d_ptr<libreverse::infrastructure::Component>, boost::no_property> >, boost:= :no_property, boost::no_property, boost::listS> const&, boost::graph_traits= <boost::adj_list_vertex_property_map>::vertex_descriptor, boost::queue<void= *, std::deque<boost::adjacency_list<boost::setS, boost::setS, boost::direct= edS, boost::property<boost::vertex_index_t, unsigned, boost::property<boost= ::vertex_name_t, boost::shared_ptr<libreverse::infrastructure::Component>, = boost::no_property> >, boost::no_property, boost::no_property, boost::listS= >, std::allocator<boost::adjacency_list<boost::setS, boost::setS, boost::di= rectedS, boost::property<boost::vertex_index_t, unsigned, boost::property<b= oost::vertex_name_t, boost::shared_ptr<libreverse::infrastructure::Componen= t>, boost::no_property> >, boost::no_property, boost::no_property, boost::l= istS> > > >&, libreverse::visitor::Graphviz_Visitor, boost::iterator_proper= ty_map<__gnu_cxx::__normal_iterator<boost::default_color_type*, std::vector= <libreverse::visitor::Graphviz_Visitor, std::allocator<libreverse::visitor:= :Graphviz_Visitor> > >, boost::adj_list_vertex_property_map<boost::no_prope= rty, unsigned, unsigned const&, boost::vertex_index_t>, libreverse::visitor= ::Graphviz_Visitor, libreverse::visitor::Graphviz_Visitor&>) (breadth_first= _search.hpp:100) =3D=3D13733=3D=3D by 0x415DAF1: void boost::detail::bfs_helper<boost::ad= jacency_list<boost::setS, boost::setS, boost::directedS, boost::property<bo= ost::vertex_index_t, unsigned, boost::property<boost::vertex_name_t, boost:= :shared_ptr<libreverse::infrastructure::Component>, boost::no_property> >, = boost::no_property, boost::no_property, boost::listS>, boost::iterator_prop= erty_map<__gnu_cxx::__normal_iterator<boost::default_color_type*, std::vect= or<__gnu_cxx, std::allocator<__gnu_cxx> > >, boost::adj_list_vertex_propert= y_map<boost::no_property, unsigned, unsigned const&, boost::vertex_index_t>= , __gnu_cxx, __gnu_cxx&>, libreverse::visitor::Graphviz_Visitor, unsigned c= onst&, boost::graph_visitor_t, boost::no_property>(boost::adjacency_list<bo= ost::setS, boost::setS, boost::directedS, boost::property<boost::vertex_ind= ex_t, unsigned, boost::property<boost::vertex_name_t, boost::shared_ptr<lib= reverse::infrastructure::Component>, boost::no_property> >, boost::no_prope= rty, boost::no_property, boost::listS>&, boost::graph_traits<__gnu_cxx>::ve= rtex_descriptor, boost::iterator_property_map<__gnu_cxx::__normal_iterator<= boost::default_color_type*, std::vector<__gnu_cxx, std::allocator<__gnu_cxx= > > >, boost::adj_list_vertex_property_map<boost::no_property, unsigned, un= signed const&, boost::vertex_index_t>, __gnu_cxx, __gnu_cxx&>, libreverse::= visitor::Graphviz_Visitor, boost::bgl_named_params<unsigned const&, boost::= graph_visitor_t, boost::no_property> const&) (breadth_first_search.hpp:185) =3D=3D13733=3D=3D by 0x415DCC1: void boost::detail::bfs_dispatch<boost::= detail::error_property_not_found>::apply<boost::adjacency_list<boost::setS,= boost::setS, boost::directedS, boost::property<boost::vertex_index_t, unsi= gned, boost::property<boost::vertex_name_t, boost::shared_ptr<libreverse::i= nfrastructure::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_list<boost::setS, bo= ost::setS, boost::directedS, boost::property<boost::vertex_index_t, unsigne= d, boost::property<boost::vertex_name_t, boost::shared_ptr<libreverse::infr= astructure::Component>, boost::no_property> >, boost::no_property, boost::n= o_property, boost::listS>&, boost::graph_traits<libreverse::visitor::Graphv= iz_Visitor>::vertex_descriptor, boost::bgl_named_params<libreverse::visitor= ::Graphviz_Visitor, boost::graph_visitor_t, boost::no_property> const&, boo= st::detail::error_property_not_found) (breadth_first_search.hpp:226) =3D=3D13733=3D=3D by 0x415DD4B: void boost::breadth_first_search<boost::= adjacency_list<boost::setS, boost::setS, boost::directedS, boost::property<= boost::vertex_index_t, unsigned, boost::property<boost::vertex_name_t, boos= t::shared_ptr<libreverse::infrastructure::Component>, boost::no_property> >= , boost::no_property, boost::no_property, boost::listS>, libreverse::visito= r::Graphviz_Visitor, boost::graph_visitor_t, boost::no_property>(boost::adj= acency_list<boost::setS, boost::setS, boost::directedS, boost::property<boo= st::vertex_index_t, unsigned, boost::property<boost::vertex_name_t, boost::= shared_ptr<libreverse::infrastructure::Component>, boost::no_property> >, b= oost::no_property, boost::no_property, boost::listS> const&, boost::graph_t= raits<libreverse::visitor::Graphviz_Visitor>::vertex_descriptor, boost::bgl= _named_params<libreverse::visitor::Graphviz_Visitor, boost::graph_visitor_t= , boost::no_property> const&) (breadth_first_search.hpp:255) =3D=3D13733=3D=3D by 0x41515D5: libreverse::api::Reverse_Impl::print_Gra= ph(libreverse::infrastructure::Component_Graph const&, std::string) const (= Reverse_Impl.cpp:189) =3D=3D13733=3D=3D by 0x4151D71: libreverse::api::Reverse_Impl::execute_A= nalysis_Section(boost::shared_ptr<std::map<std::string, boost::shared_ptr<l= ibreverse::infrastructure::Component_Graph>, std::less<std::string>, std::a= llocator<std::pair<std::string const, boost::shared_ptr<libreverse::infrast= ructure::Component_Graph> > > > >, std::pair<boost::shared_ptr<libreverse::= infrastructure::Data_Source_Base const>, boost::shared_ptr<libreverse::infr= astructure::Component> > const&) (Reverse_Impl.cpp:104) =3D=3D13733=3D=3D by 0x4144534: libreverse::api::Reverse::execute(std::s= tring const&, unsigned const&, unsigned const&) (Reverse.cpp:138) =3D=3D13733=3D=3D by 0x8055599: main (reverse.cpp:50) |
|
From: Olly B. <ol...@su...> - 2007-03-31 01:06:03
|
On 2007-03-31, Stephen Torri <st...@to...> wrote: > >> My (buggy) program dies like this: >> % valgrind: vg_malloc2.c:442 (bszW_to_pszW): Assertion 'pszW >= 0' failed. >> >> If Memcheck (the memory checker) shows any invalid reads, invalid >> writes and invalid frees in your program, the above may happen. Reason >> is that your program may trash Valgrind's low-level memory manager, >> which then dies with the above assertion, or something like this. The >> cure is to fix your program so that it doesn't do any illegal memory >> accesses. The above failure will hopefully go away after that. > > The above is a quotation from the Valgrind FAQ. Without sounding > sarcastic the answer is not that helpful. The point that I am using > Valgrind is to find the illegal memory accesses. The FAQ entry is suggesting that you fix the invalid reads, writes, or frees which valgrind reports *before* it dies like that. If you get that message without having had any reports, then the FAQ entry doesn't apply... > I started my program with the following flags when I got a similar > assertion: > > valgrind -v --tool=memcheck --leak-resolution=high ./reverse --file > kernel32.dll --leak-resolution isn't relevant for tracking invalid accesses, but it's not a problem specifying it. > What flags should I be using or is there another tool in valgrind I > should be using instead of memcheck? I do not have a strong skill using > Valgrind to find errors. So any help would be appreciated. If you haven't already, recompile without optimisation (no -O or -O2 with GCC) but keeping debug info in (keep -g). That helps make valgrind's reports easy to follow. --db-attach=yes is useful too - it lets you attach gdb at the point in execution where valgrind notices a problem so you can poke around. It can also be useful to add calls to VALGRIND_CHECK_MEM_IS_DEFINED to your program (and add '#include <valgrind/memcheck.h>'): http://www.valgrind.org/docs/manual/mc-manual.html#mc-manual.clientreqs This allows you to find out how the undefined value got into the variable in the first place (valgrind only reports when an undefined value is passed to a system call or affects control flow, since programs frequently copy around undefined bytes in harmless ways). Cheers, Olly |
|
From: Stephen T. <st...@to...> - 2007-03-31 01:37:36
|
On Sat, 2007-03-31 at 01:05 +0000, Olly Betts wrote: [....] > > What flags should I be using or is there another tool in valgrind I > > should be using instead of memcheck? I do not have a strong skill using > > Valgrind to find errors. So any help would be appreciated. > > If you haven't already, recompile without optimisation (no -O or -O2 > with GCC) but keeping debug info in (keep -g). That helps make > valgrind's reports easy to follow. > > --db-attach=yes is useful too - it lets you attach gdb at the point > in execution where valgrind notices a problem so you can poke around. > > It can also be useful to add calls to VALGRIND_CHECK_MEM_IS_DEFINED > to your program (and add '#include <valgrind/memcheck.h>'): > > http://www.valgrind.org/docs/manual/mc-manual.html#mc-manual.clientreqs So add -DVALGRIND_CHECK_MEM_IS_DEFINED to the compiler flags and then put #include <valgrind/memcheck.h> any where in the program or in all the files? Stephen |
|
From: Olly B. <ol...@su...> - 2007-03-31 01:45:03
|
On Fri, Mar 30, 2007 at 08:37:31PM -0500, Stephen Torri wrote: > On Sat, 2007-03-31 at 01:05 +0000, Olly Betts wrote: > > > It can also be useful to add calls to VALGRIND_CHECK_MEM_IS_DEFINED > > to your program (and add '#include <valgrind/memcheck.h>'): > > > > http://www.valgrind.org/docs/manual/mc-manual.html#mc-manual.clientreqs > > So add -DVALGRIND_CHECK_MEM_IS_DEFINED to the compiler flags No, add calls to the macro VALGRIND_CHECK_MEM_IS_DEFINED passing it details of the variable you want to check definedness of. As the URL I referred you to above says, the comments in memcheck.h document what the parameters are. > and then put #include <valgrind/memcheck.h> any where in the program > or in all the files? In any files where you use VALGRIND_CHECK_MEM_IS_DEFINED. Cheers, Olly |
|
From: Stephen T. <st...@to...> - 2007-03-31 02:33:42
|
On Sat, 2007-03-31 at 02:44 +0100, Olly Betts wrote: > No, add calls to the macro VALGRIND_CHECK_MEM_IS_DEFINED passing it > details of the variable you want to check definedness of. As the URL I > referred you to above says, the comments in memcheck.h document what the > parameters are. > > > and then put #include <valgrind/memcheck.h> any where in the program > > or in all the files? > > In any files where you use VALGRIND_CHECK_MEM_IS_DEFINED. > > Cheers, > Olly Ok. I understand more of what you mean now. What is the strategy you advise using this macro? I know I could go wild with putting it everywhere. Can you show me an example of how you use it? I would like to see how this works for debug release and a optimized release. Stephen |
|
From: Olly B. <ol...@su...> - 2007-03-31 06:44:26
|
On Fri, Mar 30, 2007 at 09:33:40PM -0500, Stephen Torri wrote:
> Ok. I understand more of what you mean now. What is the strategy you
> advise using this macro?
Divide and conquer!
First find the line where valgrind first reports an uninitialised
access, and right before that line call VALGRIND_CHECK_MEM_IS_DEFINED on
each of the variables mentioned in the problem line to establish which
is actually to blame (sometimes it's obvious, but as with most
debugging, it's worth double checking what seems obvious).
Then add calls back along the execution path leading to that point. If
you add a few widely spaced calls you should be able to narrow down the
area pretty quickly.
Cheers,
Olly
|
|
From: Stephen T. <st...@to...> - 2007-03-31 17:35:48
|
On Sat, 2007-03-31 at 07:44 +0100, Olly Betts wrote:
> > Ok. I understand more of what you mean now. What is the strategy you
> > advise using this macro?
>
> Divide and conquer!
>
> First find the line where valgrind first reports an uninitialised
> access, and right before that line call VALGRIND_CHECK_MEM_IS_DEFINED on
> each of the variables mentioned in the problem line to establish which
> is actually to blame (sometimes it's obvious, but as with most
> debugging, it's worth double checking what seems obvious).
Ok. I can do that. When I try to attach the debugger I get the following
message:
==9059== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- y
starting debugger
==9059== starting debugger with cmd: -nw /proc/9061/fd/1014 9061
/bin/sh: -nw: command not found
==9059==
==9059== Debugger has detached. Valgrind regains control. We continue.
I can only attach it by default if I do:
valgrind -v --tool=memcheck --db-attach=yes --db-command="gdb -nw %f %
p" ./reverse --file kernel32.dll
When I do that get that gdb is trying to attach itself but it hangs
during the attaching process:
==9069== starting debugger with cmd: gdb -nw /proc/9071/fd/1014 9071
GNU gdb Red Hat Linux (6.5-15.fc6rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host
libthread_db library "/lib/libthread_db.so.1".
Attaching to program: /proc/9071/fd/1014, process 9071
> Then add calls back along the execution path leading to that point. If
> you add a few widely spaced calls you should be able to narrow down the
> area pretty quickly.
>
> Cheers,
> Olly
Is this the correct us of VALGRIND_CHECK_MEM_IS_DEFINED? The macro wants
a int and I am sending it the pointer to a const Component_Graph and a
std::string.
void Reverse_Impl::print_Graph
( infrastructure::Component_Graph const& graph_ref,
std::string const name ) const
{
VALGRIND_CHECK_MEM_IS_DEFINED(&graph_ref,sizeof(graph_ref));
VALGRIND_CHECK_MEM_IS_DEFINED(&name,name.size());
....
}
Stephen
|
|
From: Ashley P. <as...@qu...> - 2007-04-04 12:28:47
|
Stephen Torri wrote: >> My (buggy) program dies like this: >> % valgrind: vg_malloc2.c:442 (bszW_to_pszW): Assertion 'pszW >= 0' failed. >> >> If Memcheck (the memory checker) shows any invalid reads, invalid >> writes and invalid frees in your program, the above may happen. Reason >> is that your program may trash Valgrind's low-level memory manager, >> which then dies with the above assertion, or something like this. The >> cure is to fix your program so that it doesn't do any illegal memory >> accesses. The above failure will hopefully go away after that. > > The above is a quotation from the Valgrind FAQ. Without sounding > sarcastic the answer is not that helpful. The point that I am using > Valgrind is to find the illegal memory accesses. I started my program > with the following flags when I got a similar assertion: > > valgrind -v --tool=memcheck --leak-resolution=high ./reverse --file > kernel32.dll > > What flags should I be using or is there another tool in valgrind I > should be using instead of memcheck? I do not have a strong skill using > Valgrind to find errors. So any help would be appreciated. I think as Olly said the Valgrind FAQ entry is only relevant if you *haven't* had any previous errors reported. My understanding is the error reported is your application did a invalid write to somewhere which corrupted some valgrind metadata which in time caused it to crash. You should proceed by fixing the error reported first and then re-run the application, the likelyhood is that valgrind will no longer crash. Ashley, |
|
From: Olly B. <ol...@su...> - 2007-04-05 10:36:00
|
On Sat, Mar 31, 2007 at 12:35:42PM -0500, Stephen Torri wrote:
> Is this the correct us of VALGRIND_CHECK_MEM_IS_DEFINED? The macro wants
> a int and I am sending it the pointer to a const Component_Graph and a
> std::string.
>
> void Reverse_Impl::print_Graph
> ( infrastructure::Component_Graph const& graph_ref,
> std::string const name ) const
Incidentally, did you mean to pass name by reference here?
> {
> VALGRIND_CHECK_MEM_IS_DEFINED(&graph_ref,sizeof(graph_ref));
For the case of a variable, you can write that more simply as:
VALGRIND_CHECK_VALUE_IS_DEFINED(graph_ref);
(which expands via a macro to essentially the same thing).
> VALGRIND_CHECK_MEM_IS_DEFINED(&name,name.size());
That doesn't make sense - it checks "length of string" bytes from the
start of the string object. But the std::string will probably
(inevitably I think actually) not hold the string data directly
but via a pointer or series of pointers.
So you can check the object:
VALGRIND_CHECK_VALUE_IS_DEFINED(name);
And then the string contents:
VALGRIND_CHECK_MEM_IS_DEFINED(name.data(), name.size());
Cheers,
Olly
|
|
From: Stephen T. <st...@to...> - 2007-04-05 13:23:39
|
On Thu, 2007-04-05 at 11:35 +0100, Olly Betts wrote:
> > void Reverse_Impl::print_Graph
> > ( infrastructure::Component_Graph const& graph_ref,
> > std::string const name ) const
>
> Incidentally, did you mean to pass name by reference here?
Yes. This function is not suppose to change the Component_Graph object.
I am following a code suggestion that if a function will not change a
object pass it by reference.
> > {
> > VALGRIND_CHECK_MEM_IS_DEFINED(&graph_ref,sizeof(graph_ref));
>
> For the case of a variable, you can write that more simply as:
>
> VALGRIND_CHECK_VALUE_IS_DEFINED(graph_ref);
Oh. Nice.
Stephen
|