Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
authorFaker Moatamri <faker.moatamri@sophia.inria.fr>
Wed, 13 Jan 2010 10:30:56 +0100
changeset 5909 766442c7f240
parent 5908 be7ee94b8f79
child 5910 681058254595
Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression
test.py
testpy.supp
--- a/test.py	Tue Jan 12 18:52:34 2010 +0100
+++ b/test.py	Wed Jan 13 10:30:56 2010 +0100
@@ -585,10 +585,92 @@
         if options.verbose:
             print "os.environ[\"LD_LIBRARY_PATH\"] == %s" % os.environ["LD_LIBRARY_PATH"]
 
+#
+# Short note on generating suppressions:
+#
+# See the valgrind documentation for a description of suppressions.  The easiest
+# way to generate a suppression expression is by using the valgrind 
+# --gen-suppressions option.  To do that you have to figure out how to run the 
+# test in question.
+#
+# If you do "test.py -v -g -s <suitename> then test.py will output most of what
+# you need.  For example, if you are getting a valgrind error in the
+# devices-mesh-dot11s-regression test suite, you can run:
+#
+#   ./test.py -v -g -s devices-mesh-dot11s-regression 
+#
+# You should see in the verbose output something that looks like:
+#
+#   Synchronously execute valgrind --suppressions=/home/craigdo/repos/ns-3-allinone-dev/ns-3-dev/testpy.supp
+#   --leak-check=full --error-exitcode=2 /home/craigdo/repos/ns-3-allinone-dev/ns-3-dev/build/debug/utils/test-runner 
+#   --suite=devices-mesh-dot11s-regression --basedir=/home/craigdo/repos/ns-3-allinone-dev/ns-3-dev 
+#   --tempdir=testpy-output/2010-01-12-22-47-50-CUT 
+#   --out=testpy-output/2010-01-12-22-47-50-CUT/devices-mesh-dot11s-regression.xml
+#
+# You need to pull out the useful pieces, and so could run the following to 
+# reproduce your error:
+#
+#   valgrind --suppressions=/home/craigdo/repos/ns-3-allinone-dev/ns-3-dev/testpy.supp
+#   --leak-check=full --error-exitcode=2 /home/craigdo/repos/ns-3-allinone-dev/ns-3-dev/build/debug/utils/test-runner 
+#   --suite=devices-mesh-dot11s-regression --basedir=/home/craigdo/repos/ns-3-allinone-dev/ns-3-dev 
+#   --tempdir=testpy-output 
+#
+# Hint: Use the first part of the command as is, and point the "tempdir" to 
+# somewhere real.  You don't need to specify an "out" file.
+#
+# When you run the above command you should see your valgrind error.  The 
+# suppression expression(s) can be generated by adding the --gen-suppressions=yes
+# option to valgrind.  Use something like:
+#
+#   valgrind --gen-suppressions=yes --suppressions=/home/craigdo/repos/ns-3-allinone-dev/ns-3-dev/testpy.supp
+#   --leak-check=full --error-exitcode=2 /home/craigdo/repos/ns-3-allinone-dev/ns-3-dev/build/debug/utils/test-runner 
+#   --suite=devices-mesh-dot11s-regression --basedir=/home/craigdo/repos/ns-3-allinone-dev/ns-3-dev 
+#   --tempdir=testpy-output 
+#
+# Now when valgrind detects an error it will ask:
+#
+#   ==27235== ---- Print suppression ? --- [Return/N/n/Y/y/C/c] ----
+#
+# to which you just enter 'y'<ret>.
+#
+# You will be provided with a suppression expression that looks something like
+# the following:
+#   {
+#     <insert_a_suppression_name_here>
+#     Memcheck:Addr8
+#     fun:_ZN3ns36dot11s15HwmpProtocolMac8SendPreqESt6vectorINS0_6IePreqESaIS3_EE
+#     fun:_ZN3ns36dot11s15HwmpProtocolMac10SendMyPreqEv
+#     fun:_ZN3ns36dot11s15HwmpProtocolMac18RequestDestinationENS_12Mac48AddressEjj
+#     ...
+#     the rest of the stack frame
+#     ...
+#   }
+#
+# You need to add a supression name which will only be printed out by valgrind in 
+# verbose mode (but it needs to be there in any case).  The entire stack frame is
+# shown to completely characterize the error, but in most cases you won't need 
+# all of that info.  For example, if you want to turn off all errors that happen
+# when the function (fun:) is called, you can just delete the rest of the stack
+# frame.  You can also use wildcards to make the mangled signatures more readable.
+#
+# I added the following to the testpy.supp file for this particular error:
+#
+#   {
+#     Supress invalid read size errors in SendPreq() when using HwmpProtocolMac
+#     Memcheck:Addr8
+#     fun:*HwmpProtocolMac*SendPreq*
+#   }
+#
+# Now, when you run valgrind the error will be suppressed.
+#
+VALGRIND_SUPPRESSIONS_FILE = "testpy.supp"
+
 def run_job_synchronously(shell_command, directory, valgrind):
+    (base, build) = os.path.split (NS3_BUILDDIR)
+    suppressions_path = os.path.join (base, VALGRIND_SUPPRESSIONS_FILE)
     path_cmd = os.path.join (NS3_BUILDDIR, NS3_ACTIVE_VARIANT, shell_command)
     if valgrind:
-        cmd = "valgrind --leak-check=full --error-exitcode=2 %s" % path_cmd
+        cmd = "valgrind --suppressions=%s --leak-check=full --error-exitcode=2 %s" % (suppressions_path, path_cmd)
     else:
         cmd = path_cmd
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testpy.supp	Wed Jan 13 10:30:56 2010 +0100
@@ -0,0 +1,5 @@
+{
+  Supress invalid read size errors in SendPreq() when using HwmpProtocolMac
+  Memcheck:Addr8
+  fun:*HwmpProtocolMac*SendPreq*
+}