We have been having some really wierd errors on our mud, so we want to valgrind to try to find some data corruption. To make the output close to usable, I have been using code to clean all memory that has been allocated, then booting and shutting down right away. I have been able to fix most issues with it, except for some error about conditional jumps in deflate and get_hostbyname, but I have a few that I can't figure out:
bool RACE_DATA::load_race_file(char *racefile)
{
char filename[256];
RACE_DATA *race;
FILE *fp;
snprintf(filename, 256, "%s%s", RACES_DIR, racefile);
if ((fp = fopen(filename, "r")) != NULL)
{
for (;;)
{
char letter;
char *word;
letter = fread_letter(fp);
if (letter == '*')
{
fread_to_eol(fp);
continue;
}
if (letter != '#')
{
bug("Load_race_file: # not found.", 0);
break;
}
word = fread_word(fp);
if (!str_cmp(word, "RACE"))
{
race = new RACE_DATA;
race->load(fp);
races.push_back(race); /* Line 309 */
break;
}
else if (!str_cmp(word, "END"))
break;
else
{
bug("Load_race_file: bad section: %s.", word);
break;
}
}
FCLOSE(fp);
return TRUE;
}
return FALSE;
}
And I am getting this error:
==22665== 20 bytes in 5 blocks are still reachable in loss record 2 of 10
==22665== at 0x1B904727: operator new(unsigned) (vg_replace_malloc.c:132)
==22665== by 0x1B9A0EC1: __gnu_cxx::__pool<true>::_M_initialize(void (*)(void*)) (in /usr/lib/libstdc++.so.6.0.5)
==22665== by 0x80757E8: __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true>::_S_initialize() (mt_allocator.h:472)
==22665== by 0x8073E28: __gnu_cxx::__pool<true>::_M_initialize_once(void (*)()) (mt_allocator.h:332)
==22665== by 0x807510E: __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true>::_S_initialize_once() (mt_allocator.h:460)
==22665== by 0x81B8FC6: __gnu_cxx::__mt_alloc<std::_List_node<RACE_DATA*>, __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, true> >::allocate(unsigned, void const*) (mt_allocator.h:693)
==22665== by 0x81B90F1: std::_List_base<RACE_DATA*, std::allocator<RACE_DATA*> >::_M_get_node() (stl_list.h:312)
==22665== by 0x81B910A: std::list<RACE_DATA*, std::allocator<RACE_DATA*> >::_M_create_node(RACE_DATA* const&) (stl_list.h:437)
==22665== by 0x81B9167: std::list<RACE_DATA*, std::allocator<RACE_DATA*> >::_M_insert(std::_List_iterator<RACE_DATA*>, RACE_DATA* const&) (stl_list.h:1151)
==22665== by 0x81B91B2: std::list<RACE_DATA*, std::allocator<RACE_DATA*> >::push_back(RACE_DATA* const&) (stl_list.h:773)
==22665== by 0x81B87D1: RACE_DATA::load_race_file(char*) (races.c:309)
==22665== by 0x81B89A1: RACE_DATA::load_races() (races.c:367)
==22665== by 0x81230C1: boot_db(bool) (db.c:942)
==22665== by 0x810AEA9: main (comm.c:344)
==22665== 120 bytes in 1 blocks are still reachable in loss record 7 of 10
==22665== at 0x1B904727: operator new(unsigned) (vg_replace_malloc.c:132)
==22665== by 0x81B878B: RACE_DATA::load_race_file(char*) (races.c:307)
==22665== by 0x81B89A1: RACE_DATA::load_races() (races.c:367)
==22665== by 0x81230C1: boot_db(bool) (db.c:942)
==22665== by 0x810AEA9: main (comm.c:344)
Now, does this mean that I am putting bad data into the list, or that maybe I'm not traversing the whole list to free it? Any insight would be great.
|