I've been trying to debug a comparatively infrequent, impossible-to-produce-on-demand memory issue for some time now, and I think today provided the most useful valgrind output thus far. Below are the relevant lines:
==25808== Conditional jump or move depends on uninitialised value(s)
==25808== at 0x4EF14CE: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==25808== by 0x491EA7: app::symbol_parameters::~symbol_parameters() (App.h:26)
==25808== by 0x4B7E04: app::AddSymbol(std::string, int, unsigned long) (xyz_symbol_add.cpp:43)
==25808== by 0x4B3269: AppStartup(int, char**, char const*) (AppBase.cpp:332)
==25808== by 0x48CE74: main (App.cpp:54)
==25808==
==25808== Use of uninitialised value of size 8
==25808== at 0x4E9264D: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==25808== by 0x4EF14DE: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==25808== by 0x491EA7: app::symbol_parameters::~symbol_parameters() (App.h:26)
==25808== by 0x4B7E04: app::AddSymbol(std::string, int, unsigned long) (xyz_symbol_add.cpp:43)
==25808== by 0x4B3269: AppStartup(int, char**, char const*) (AppBase.cpp:332)
==25808== by 0x48CE74: main (App.cpp:54)
==25808==
==25808== Conditional jump or move depends on uninitialised value(s)
==25808== at 0x4C2C272: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25808== by 0x4EF14DE: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==25808== by 0x491EA7: app::symbol_parameters::~symbol_parameters() (App.h:26)
==25808== by 0x4B7E04: app::AddSymbol(std::string, int, unsigned long) (xyz_symbol_add.cpp:43)
==25808== by 0x4B3269: AppStartup(int, char**, char const*) (AppBase.cpp:332)
==25808== by 0x48CE74: main (App.cpp:54)
==25808==
==25808== Invalid free() / delete / delete[] / realloc()
==25808== at 0x4C2C2BC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25808== by 0x4EF14DE: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==25808== by 0x491EA7: app::symbol_parameters::~symbol_parameters() (App.h:26)
==25808== by 0x4B7E04: app::AddSymbol(std::string, int, unsigned long) (xyz_symbol_add.cpp:43)
==25808== by 0x4B3269: AppStartup(int, char**, char const*) (AppBase.cpp:332)
==25808== by 0x48CE74: main (App.cpp:54)
==25808== Address 0x5c343e8 is in the Data segment of /lib/x86_64-linux-gnu/libc-2.19.so
==25808==
==25808== Conditional jump or move depends on uninitialised value(s)
==25808== at 0x4EF14CE: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==25808== by 0x491EC7: app::symbol_parameters::~symbol_parameters() (App.h:26)
==25808== by 0x4B7E04: app::AddSymbol(std::string, int, unsigned long) (xyz_symbol_add.cpp:43)
==25808== by 0x4B3269: AppStartup(int, char**, char const*) (AppBase.cpp:332)
==25808== by 0x48CE74: main (App.cpp:54)
==25808==
==25808== Use of uninitialised value of size 8
==25808== at 0x4E9264D: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==25808== by 0x4EF14DE: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==25808== by 0x491EC7: app::symbol_parameters::~symbol_parameters() (App.h:26)
==25808== by 0x4B7E04: app::AddSymbol(std::string, int, unsigned long) (xyz_symbol_add.cpp:43)
==25808== by 0x4B3269: AppStartup(int, char**, char const*) (AppBase.cpp:332)
==25808== by 0x48CE74: main (App.cpp:54)
==25808==
==25808==
==25808== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==25808== Bad permissions for mapped region at address 0x58EF4D4
==25808== at 0x4E9264D: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==25808== by 0x4EF14DE: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19)
==25808== by 0x491EC7: app::symbol_parameters::~symbol_parameters() (App.h:26)
==25808== by 0x4B7E04: app::AddSymbol(std::string, int, unsigned long) (xyz_symbol_add.cpp:43)
==25808== by 0x4B3269: AppStartup(int, char**, char const*) (AppBase.cpp:332)
==25808== by 0x48CE74: main (App.cpp:54)
And here are the lines about which valgrind most directly complains:
App.h:26-40
struct symbol_parameters
{
string symbol;
//...
};
xyz_symbol_add.cpp:18-43
struct symbol_parameters
{
string symbol;
};
//...
void AddSymbol(string sym, int32_t psn, uint64_t pr)
{
string symb=format_symbol_local(sym);
//...
symbol_parameters p{symb};
//...
And here's format_symbol_local()
string format_symbol_local(string symbol)
{
// convert .PR to -
size_t found = symbol.find(".PR");
if(string::npos==found) return symbol;
return symbol.replace(found,3,"-");
}
AppBase.cpp:327-333
for(LibAbcCallBack::Position position : xyz_params.position_list)
{
if(position.quantity > 0)
{
AddSymbol(position.symbol, position.quantity);
}
}
And finally, App.cpp:54 is just a line from main(), calling AppStartup(). Nothing surprising there.
While there are names for most of the functions that valgrind takes issue with, I'm having a hard time deriving anything useful from the output. Where should I be looking from here?
Aucun commentaire:
Enregistrer un commentaire