Bug 919

Summary: minstrel does not pass valgrind tests
Product: ns-3 Reporter: Nicola Baldo <nicola>
Component: wifiAssignee: duy <dnlove>
Status: RESOLVED FIXED    
Severity: normal CC: mathieu.lacage, ns-bugs
Priority: P3    
Version: ns-3-dev   
Hardware: All   
OS: All   
Attachments: valgrind trace
patched memory leak

Description Nicola Baldo 2010-05-21 04:16:17 UTC
the following does not pass valgrind tests:
 examples/wireless/multirate --totalTime=0.3s --rateManager=ns3::MinstrelWifiManager

when this is fixed, it should be added to test.py
Comment 1 duy 2010-05-21 23:57:43 UTC
Created attachment 875 [details]
valgrind trace
Comment 2 duy 2010-05-21 23:58:53 UTC
(In reply to comment #0)
> the following does not pass valgrind tests:
>  examples/wireless/multirate --totalTime=0.3s
> --rateManager=ns3::MinstrelWifiManager
> 
> when this is fixed, it should be added to test.py

Valgrind complains about the allocation in line 240 and 241 in
minstrel-wifi-manager.cc

240       station->m_minstrelTable = MinstrelRate(GetNSupported (station));
241       station->m_sampleTable = SampleRate(GetNSupported (station),

I thought c++ STL automatically handles allocation and deallocation?  Any
suggestions?
Comment 3 duy 2010-05-22 17:09:36 UTC
> Valgrind complains about the allocation in line 240 and 241 in
> minstrel-wifi-manager.cc
> 
> 240       station->m_minstrelTable = MinstrelRate(GetNSupported (station));
> 241       station->m_sampleTable = SampleRate(GetNSupported (station),
> 
> I thought c++ STL automatically handles allocation and deallocation?  Any
> suggestions?

We could move those two lines and allocate memory in 

WifiRemoteStation *
MinstrelWifiManager::DoCreateStation 

However, GetNSupported (station) values have not been initialized yet in the DoCreateStation, this is why I defer and initialize them in

WifiMode
MinstrelWifiManager::DoGetDataMode
Comment 4 duy 2010-05-26 14:32:01 UTC
Created attachment 881 [details]
patched memory leak

this patch fixed the memory leak problem in minstrel.  m_stations do not seem to be able to allocate and de-allocate memory correctly, so I placed all the allocation back in the MinstrelWifiManager as in my original implementation.  I did a valgrind run with on minstrel with wifi-adhoc and multirate they both passed the memory leak successfully. 

I am not sure if Bug 802 is related or not, but the valgrind runs points to

==4079== Invalid read of size 4
==4079==    at 0x47D129E: ns3::TimeUnit<1>::operator=(ns3::TimeUnit<1> const&) (nstime.h:424)
==4079==    by 0x4DFF96F: ns3::MinstrelWifiManager::UpdateStats(ns3::MinstrelWifiRemoteStation*) (minstrel-wifi-manager.cc:574)
Comment 5 duy 2010-06-04 01:38:49 UTC
changeset:   6337:92c95748a915
tag:         tip
user:        Duy Nguyen <duy@soe.ucsc.edu>
date:        Thu Jun 03 22:38:44 2010 -0700
summary:     Fixed Bug 802 and Bug 919