|
From: Stephen T. <st...@to...> - 2007-05-22 15:09:01
|
I am commiting myself to fully understanding how to use valgrind. In the
past I have used rather haphazardly but no more. Below is an example
error produced using:
valgrind -v --leak-check=full ./pedump --file potential/hh.exe
==28647== Invalid write of size 4
==28647== at 0x806C7D0: boost::detail::shared_count::shared_count() (/usr/include/boost/detail/shared_count.hpp:66)
==28647== by 0x806DC00: boost::shared_ptr<libreverse::data_container::Memory_Map>::shared_ptr() (/usr/include/boost/shared_ptr.hpp:119)
==28647== by 0x41D7E24: libreverse::io::File::File(boost::shared_ptr<libreverse::io::File_ID>) (File.cpp:19)
==28647== by 0x808FFB4: libreverse::wpef_module::PE_File<32>::PE_File(boost::shared_ptr<libreverse::io::File_ID>) (/usr/local/include/libreverse/io/input/File_Readers/Windows_PE/PE_File_T.cpp:27)
==28647== by 0x80900E2: libreverse::wpef_module::Reader<32>::Reader(boost::shared_ptr<libreverse::io::File_ID>, bool, bool) (/usr/local/include/libreverse/io/input/File_Readers/Windows_PE/Reader_T.cpp:43)
==28647== by 0x806C44D: main (pedump.cpp:38)
==28647== Address 0x4400730 is 0 bytes after a block of size 24 alloc'd
==28647== at 0x40054E5: malloc (vg_replace_malloc.c:149)
==28647== by 0x4188AFF: allocate(unsigned, int) (sp_debug_hooks.cpp:44)
==28647== by 0x4188C87: operator new(unsigned) (sp_debug_hooks.cpp:65)
==28647== by 0x80900CD: libreverse::wpef_module::Reader<32>::Reader(boost::shared_ptr<libreverse::io::File_ID>, bool, bool) (/usr/local/include/libreverse/io/input/File_Readers/Windows_PE/Reader_T.cpp:43)
==28647== by 0x806C44D: main (pedump.cpp:38)
Now the valgrind documentation says that I should interpret this as a:
What: Invalid write
Where: 0x4400730
Who: 0x806C7D0 by shared_count.hpp:66
From: 0x806DC00 by shared_ptr.hpp:119
When I look at the first place the error is in my code it is in the constructor for the File class.
119: File::File ( File_ID::ptr_t filename )
120: {
121: Trace::write_Trace ( TraceLevel::TraceDetail,
122: "Entering File constructor (file_id)" );
123:
124: if ( filename.get() == 0 )
125: {
126: std::cerr << "File ID pointer for file is not set (NULL)" << std::endl;
127:
128: std::cerr << boost::format("Exception throw in %s at line %d")
129: % __FILE__
130: % __LINE__
131: << std::endl;
132:
133: throw errors::IO_Exception
134: (errors::IO_Exception::NULL_POINTER);
135: }
136: else
137: {
138: m_file_ref = filename;
139: }
140:
141: Trace::write_Trace ( TraceLevel::TraceDetail,
142: "Exiting File constructor (file id)" );
143:
144: }
Is this error message saying that I am trying to a invalid write in the File_ID function argument or the constructor?
Stephen
|