You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
else if (type == "Icon Group")
{
auto iGroup = std::make_unique<ResourceIconGroup>();
iGroup->setIconGroupID(iconGroupIDcounter);
resource = std::move(iGroup);
resourceTable->addResourceIconGroup(static_cast<ResourceIconGroup *>(resource.get()));
iconGroupIDcounter++;
}
////////////////////////////
iGroup is ResourceIconGroup class and resource is Resource class. We have ResourceIconGroup inherits from Resource class. The memory leak happen when resource is destroyed, the memory of ResourceIconGroup class is not destroyed because Resource class doesn't have a virtual destruction.
For more information, please find the Valgrind log below.
==27545== 32 bytes in 1 blocks are definitely lost in loss record 29 of 56
==27545== at 0x4C2A593: operator new(unsigned long) (vg_replace_malloc.c:344)
==27545== by 0x56F3015: __gnu_cxx::new_allocatorretdec::fileformat::ResourceIcon*::allocate(unsigned long, void const*) (new_allocator.h:111)
==27545== by 0x56F2B2B: std::allocator_traits<std::allocatorretdec::fileformat::ResourceIcon* >::allocate(std::allocatorretdec::fileformat::ResourceIcon*&, unsigned long) (alloc_traits.h:436)
==27545== by 0x56F2213: std::_Vector_base<retdec::fileformat::ResourceIcon*, std::allocatorretdec::fileformat::ResourceIcon* >::_M_allocate(unsigned long) (stl_vector.h:172)
==27545== by 0x56F14DC: void std::vector<retdec::fileformat::ResourceIcon*, std::allocatorretdec::fileformat::ResourceIcon* >::_M_realloc_insert<retdec::fileformat::ResourceIcon* const&>(__gnu_cxx::__normal_iterator<retdec::fileformat::ResourceIcon**, std::vector<retdec::fileformat::ResourceIcon*, std::allocatorretdec::fileformat::ResourceIcon* > >, retdec::fileformat::ResourceIcon* const&) (vector.tcc:406)
==27545== by 0x56F0861: std::vector<retdec::fileformat::ResourceIcon*, std::allocatorretdec::fileformat::ResourceIcon* >::push_back(retdec::fileformat::ResourceIcon* const&) (stl_vector.h:948)
==27545== by 0x5839008: retdec::fileformat::ResourceIconGroup::addIcon(retdec::fileformat::ResourceIcon*) (resource_icon_group.cpp:314)
==27545== by 0x56EF816: retdec::fileformat::ResourceTable::linkResourceIconGroups() (resource_table.cpp:799)
==27545== by 0x571948D: retdec::fileformat::PeFormat::loadResources() (pe_format.cpp:1793)
==27545== by 0x5712FCD: retdec::fileformat::PeFormat::initStructures(std::string const&) (pe_format.cpp:654)
==27545== by 0x571203E: retdec::fileformat::PeFormat::PeFormat(std::string const&, std::string const&, retdec::fileformat::LoadFlags) (pe_format.cpp:513)
==27545== by 0x566D46D: retdec::fileinfo::PeWrapper::PeWrapper(std::string const&, std::string const&, retdec::fileformat::LoadFlags) (pe_wrapper.cpp:98)
I tried to add the a virtual destruction in Resource class. Then there is no leak anymore
The text was updated successfully, but these errors were encountered:
At the function PeFormat::loadResources():
////////////////////////////
////////////////////////////
iGroup is ResourceIconGroup class and resource is Resource class. We have ResourceIconGroup inherits from Resource class. The memory leak happen when resource is destroyed, the memory of ResourceIconGroup class is not destroyed because Resource class doesn't have a virtual destruction.
For more information, please find the Valgrind log below.
==27545== 32 bytes in 1 blocks are definitely lost in loss record 29 of 56
==27545== at 0x4C2A593: operator new(unsigned long) (vg_replace_malloc.c:344)
==27545== by 0x56F3015: __gnu_cxx::new_allocatorretdec::fileformat::ResourceIcon*::allocate(unsigned long, void const*) (new_allocator.h:111)
==27545== by 0x56F2B2B: std::allocator_traits<std::allocatorretdec::fileformat::ResourceIcon* >::allocate(std::allocatorretdec::fileformat::ResourceIcon*&, unsigned long) (alloc_traits.h:436)
==27545== by 0x56F2213: std::_Vector_base<retdec::fileformat::ResourceIcon*, std::allocatorretdec::fileformat::ResourceIcon* >::_M_allocate(unsigned long) (stl_vector.h:172)
==27545== by 0x56F14DC: void std::vector<retdec::fileformat::ResourceIcon*, std::allocatorretdec::fileformat::ResourceIcon* >::_M_realloc_insert<retdec::fileformat::ResourceIcon* const&>(__gnu_cxx::__normal_iterator<retdec::fileformat::ResourceIcon**, std::vector<retdec::fileformat::ResourceIcon*, std::allocatorretdec::fileformat::ResourceIcon* > >, retdec::fileformat::ResourceIcon* const&) (vector.tcc:406)
==27545== by 0x56F0861: std::vector<retdec::fileformat::ResourceIcon*, std::allocatorretdec::fileformat::ResourceIcon* >::push_back(retdec::fileformat::ResourceIcon* const&) (stl_vector.h:948)
==27545== by 0x5839008: retdec::fileformat::ResourceIconGroup::addIcon(retdec::fileformat::ResourceIcon*) (resource_icon_group.cpp:314)
==27545== by 0x56EF816: retdec::fileformat::ResourceTable::linkResourceIconGroups() (resource_table.cpp:799)
==27545== by 0x571948D: retdec::fileformat::PeFormat::loadResources() (pe_format.cpp:1793)
==27545== by 0x5712FCD: retdec::fileformat::PeFormat::initStructures(std::string const&) (pe_format.cpp:654)
==27545== by 0x571203E: retdec::fileformat::PeFormat::PeFormat(std::string const&, std::string const&, retdec::fileformat::LoadFlags) (pe_format.cpp:513)
==27545== by 0x566D46D: retdec::fileinfo::PeWrapper::PeWrapper(std::string const&, std::string const&, retdec::fileformat::LoadFlags) (pe_wrapper.cpp:98)
I tried to add the a virtual destruction in Resource class. Then there is no leak anymore
The text was updated successfully, but these errors were encountered: