Bug 1555

Summary: valgrind error in time code
Product: ns-3 Reporter: Tom Henderson <tomh>
Component: coreAssignee: Mathieu Lacage <mathieu.lacage>
Status: RESOLVED FIXED    
Severity: blocker CC: ns-bugs, watrous
Priority: P5    
Version: pre-release   
Hardware: PC   
OS: Linux   
Bug Depends on: 954    
Bug Blocks:    

Description Tom Henderson 2012-12-13 14:40:52 UTC
Some ns-3 tests and examples do not call Simulator::Run(), and hence Time::FreezeResolution() is not called and the times set is not deleted.

To reproduce, run this program under valgrind:

#include "ns3/core-module.h"

NS_LOG_COMPONENT_DEFINE ("s");

using namespace ns3;

int
main (int argc, char *argv[])
{
  return 0;
}

The below patch can resolve the error:

diff -r f094300690db src/core/model/time.cc
--- a/src/core/model/time.cc	Wed Dec 12 22:43:49 2012 -0800
+++ b/src/core/model/time.cc	Thu Dec 13 08:56:14 2012 -0800
@@ -279,5 +279,14 @@
 ATTRIBUTE_VALUE_IMPLEMENT (Time);
 ATTRIBUTE_CHECKER_IMPLEMENT (Time);

+// dummy object to make sure Time::FreezeResolution is called at least once
+class _dummy
+{
+public:
+  ~_dummy () { Time::FreezeResolution();}
+};
+
+static _dummy dummy;
+
 } // namespace ns3
Comment 1 Mitch Watrous 2012-12-13 16:10:43 UTC
This patch did not bug 1554, which has to do with seg faults in the first.py example on ns-regresssion, i.e. it did not make first.py work on that machine.
Comment 2 Mathieu Lacage 2012-12-14 07:30:34 UTC
+1 for merging if it is not done already
Comment 3 Tom Henderson 2012-12-14 17:55:33 UTC
No need to merge; current patch to 954 will be reverted.

I'll close this once the 954 patch is reverted.
Comment 4 Tom Henderson 2012-12-17 00:50:59 UTC
fixed with revert of bug 954 patch