diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2016-11-08 22:07:34 +0100 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2016-11-15 17:01:24 +0100 |
commit | a804627837c69920f34dcfa6d2331e16c64f8fd6 (patch) | |
tree | 1401d6d8f45ce5cfd9b345f2923115e574f1f375 /tools/run-valgrind.py | |
parent | e762ca0060dcce3e047cacc7824ba07e0fb045f3 (diff) | |
download | node-new-a804627837c69920f34dcfa6d2331e16c64f8fd6.tar.gz |
tools: make run-valgrind.py useful
Node.js does not clean up on exit so don't complain about memory leaks
but do complain about invalid memory access. In the future we may want
to add a cleanup-on-exit flag or put together a suppression list.
PR-URL: https://github.com/nodejs/node/pull/9520
Reviewed By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'tools/run-valgrind.py')
-rwxr-xr-x | tools/run-valgrind.py | 43 |
1 files changed, 7 insertions, 36 deletions
diff --git a/tools/run-valgrind.py b/tools/run-valgrind.py index 9e26dbed8e..ae1a3194ca 100755 --- a/tools/run-valgrind.py +++ b/tools/run-valgrind.py @@ -27,32 +27,26 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# Simple wrapper for running valgrind and checking the output on -# stderr for memory leaks. -# Uses valgrind from third_party/valgrind. Assumes the executable is passed -# with a path relative to the v8 root. - - from os import path -import platform -import re import subprocess import sys -V8_ROOT = path.dirname(path.dirname(path.abspath(__file__))) +NODE_ROOT = path.dirname(path.dirname(path.abspath(__file__))) VALGRIND_ARGUMENTS = [ 'valgrind', '--error-exitcode=1', - '--leak-check=full', '--smc-check=all', + # Node.js does not clean up on exit so don't complain about + # memory leaks but do complain about invalid memory access. + '--quiet', ] if len(sys.argv) < 2: print 'Please provide an executable to analyze.' sys.exit(1) -executable = path.join(V8_ROOT, sys.argv[1]) +executable = path.join(NODE_ROOT, sys.argv[1]) if not path.exists(executable): print 'Cannot find the file specified: %s' % executable sys.exit(1) @@ -62,33 +56,10 @@ command = VALGRIND_ARGUMENTS + [executable] + sys.argv[2:] # Run valgrind. process = subprocess.Popen(command, stderr=subprocess.PIPE) -code = process.wait(); -errors = process.stderr.readlines(); +code = process.wait() +errors = process.stderr.readlines() # If valgrind produced an error, we report that to the user. if code != 0: sys.stderr.writelines(errors) sys.exit(code) - -# Look through the leak details and make sure that we don't -# have any definitely, indirectly, and possibly lost bytes. -LEAK_RE = r"(?:definitely|indirectly|possibly) lost: " -LEAK_LINE_MATCHER = re.compile(LEAK_RE) -LEAK_OKAY_MATCHER = re.compile(r"lost: 0 bytes in 0 blocks") -leaks = [] -for line in errors: - if LEAK_LINE_MATCHER.search(line): - leaks.append(line) - if not LEAK_OKAY_MATCHER.search(line): - sys.stderr.writelines(errors) - sys.exit(1) - -# Make sure we found between 2 and 3 leak lines. -if len(leaks) < 2 or len(leaks) > 3: - sys.stderr.writelines(errors) - sys.stderr.write('\n\n#### Malformed valgrind output.\n#### Exiting.\n') - sys.exit(1) - -# No leaks found. -sys.stderr.writelines(errors) -sys.exit(0) |