From 7623a960a5c01d666b3f6761b58f9ec1c805c75a Mon Sep 17 00:00:00 2001 From: Faker Moatamri Date: Wed, 13 Jan 2010 10:30:56 +0100 Subject: [PATCH] Bug 781: Suppress the valgrind error: Invalid read size of 8 in TestSuite devices-mesh-dot11s-regression --- test.py | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++- testpy.supp | 5 ++++ 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 testpy.supp diff --git a/test.py b/test.py index 979eaeacd..0895ad65d 100755 --- a/test.py +++ b/test.py @@ -585,10 +585,92 @@ def make_library_path(): 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 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'. +# +# You will be provided with a suppression expression that looks something like +# the following: +# { +# +# 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 diff --git a/testpy.supp b/testpy.supp new file mode 100644 index 000000000..ff7deb13f --- /dev/null +++ b/testpy.supp @@ -0,0 +1,5 @@ +{ + Supress invalid read size errors in SendPreq() when using HwmpProtocolMac + Memcheck:Addr8 + fun:*HwmpProtocolMac*SendPreq* +}