|
Bugzilla – Full Text Bug Listing |
| Summary: | valgrind error when finalizing PacketMetadata | ||
|---|---|---|---|
| Product: | ns-3 | Reporter: | Gustavo J. A. M. Carneiro <gjcarneiro> |
| Component: | core | Assignee: | ns-bugs <ns-bugs> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | P1 | ||
| Version: | pre-release | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Attachments: | possible patch | ||
|
Description
Gustavo J. A. M. Carneiro
2007-09-27 12:56:00 UTC
OK, I think I understand the problem better now... ==14271== by 0x5086AD2: std::vector<ns3::PacketMetadata::Data*, std::allocator<ns3::PacketMetadata::Data*> >::push_back(ns3::PacketMetadata::Data* const&) (stl_vector.h:606) ==14271== by 0x5083892: ns3::PacketMetadata::Recycle(ns3::PacketMetadata::Data*) (packet-metadata.cc:655) ==14271== by 0x40959E: ns3::PacketMetadata::~PacketMetadata() (packet-metadata.h:340) ==14271== by 0x409681: ns3::Packet::~Packet() (packet.h:75) When the packet is destroyed, it tries to add the metadata chunk back to the free list. But the free list vector has already been destroyed at that point... Now, any opinions on which is the best solution: 1. Add a boolean global variable telling when the free list has already been destroyed; 2. Make the "static DataFreeList m_freeList;" member of PacketMetadata a pointer, allocate it with new, never deallocate. 3. Other option? Created attachment 70 [details]
possible patch
(In reply to comment #1) > OK, I think I understand the problem better now... > > ==14271== by 0x5086AD2: std::vector<ns3::PacketMetadata::Data*, > std::allocator<ns3::PacketMetadata::Data*> > >::push_back(ns3::PacketMetadata::Data* const&) (stl_vector.h:606) > ==14271== by 0x5083892: > ns3::PacketMetadata::Recycle(ns3::PacketMetadata::Data*) > (packet-metadata.cc:655) > ==14271== by 0x40959E: ns3::PacketMetadata::~PacketMetadata() > (packet-metadata.h:340) > ==14271== by 0x409681: ns3::Packet::~Packet() (packet.h:75) > > > When the packet is destroyed, it tries to add the metadata chunk back to the > free list. But the free list vector has already been destroyed at that > point... ok. > > Now, any opinions on which is the best solution: > 1. Add a boolean global variable telling when the free list has already been > destroyed; That might work but it leaves me a bad taste in the mouth afterwards. > 2. Make the "static DataFreeList m_freeList;" member of PacketMetadata a > pointer, allocate it with new, never deallocate. This is what was implemented before: it just triggers memory leak reports by valgrind. > 3. Other option? I can't think of any better option. Potentially, I think that option 1) is the most useful because it avoids memory leak reports and eliminates this problem. OK, fixed with boolean flag (m_enable reused for this). |