Add tooling for running under Valgrind.
authorMatt McCutchen <matt@mattmccutchen.net>
Mon, 22 Mar 2010 17:07:26 +0000 (17:07 +0000)
committerMatt McCutchen <matt@mattmccutchen.net>
Mon, 22 Mar 2010 17:07:26 +0000 (17:07 +0000)
SVN-Revision: 6622

tools/valgrind/README [new file with mode: 0644]
tools/valgrind/run [new file with mode: 0755]
tools/valgrind/supertux.supp [new file with mode: 0644]

diff --git a/tools/valgrind/README b/tools/valgrind/README
new file mode 100644 (file)
index 0000000..010ea15
--- /dev/null
@@ -0,0 +1,19 @@
+You can use this script and suppressions file to run SuperTux under Valgrind
+( http://www.valgrind.org/ ) to catch memory errors and leaks.
+
+Some things to be aware of:
+
+- Some C++ objects appear to use interior pointers, which will cause valgrind to
+  report parts of their still-reachable instances as "possibly lost".  You can
+  ignore those reports.
+
+- In the GNU C++ library, a std::string object contains a pointer to a
+  heap-allocated "representation" buffer containing the actual data.  If you
+  free a heap-allocated std::string S without destructing it (uncommon but not
+  unheard of), you'll leak the representation.  But representations are shared
+  and copied on write, so if S was a copy of another string S', Valgrind will
+  blame the leak on the code that created S' because that was when the
+  representation was allocated.  (Valgrind doesn't know any better without
+  instrumenting constructors and destructors.)  Watch out for this.  When it
+  first happened to me (Matt McCutchen), I was stumped for a while; finally,
+  I wrote some small test programs and realized what was happening.
diff --git a/tools/valgrind/run b/tools/valgrind/run
new file mode 100755 (executable)
index 0000000..1eed452
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+# Script to launch supertux under valgrind for memory error/leak checking.
+# This is meant to be called as "tools/valgrind/run" from the top of the tree.
+
+valgrind --log-file=valgrind.log --suppressions=tools/valgrind/supertux.supp \
+       --gen-suppressions=all --leak-check=full --num-callers=20 \
+       ./supertux2 "$@"
diff --git a/tools/valgrind/supertux.supp b/tools/valgrind/supertux.supp
new file mode 100644 (file)
index 0000000..1683b1a
--- /dev/null
@@ -0,0 +1,79 @@
+# Valgrind suppressions file for SuperTux
+#
+# Started by Matt McCutchen <matt@mattmccutchen.net> 2010-02-18
+
+# Various errors observed in libraries and not investigated.
+{
+   SDL-Cond
+   Memcheck:Cond
+   fun:SDL_SYS_JoystickInit
+}
+{
+   SDL-Cond2
+   Memcheck:Cond
+   fun:X11_SetKeyboardState
+}
+{
+   nvidia-libGLcore-Cond
+   Memcheck:Cond
+   obj:/usr/lib*/nvidia/libGLcore.so*
+}
+{
+   nvidia-libGL-malloc-Leak
+   Memcheck:Leak
+   fun:malloc
+   obj:/usr/lib*/nvidia/libGL.so*
+}
+{
+   nvidia-libGL-calloc-Leak
+   Memcheck:Leak
+   fun:calloc
+   obj:/usr/lib*/nvidia/libGL.so*
+}
+{
+   nvidia-libGL-realloc-Leak
+   Memcheck:Leak
+   fun:realloc
+   obj:/usr/lib*/nvidia/libGL.so*
+}
+{
+   nvidia-libGL-dlopen-Leak
+   Memcheck:Leak
+   ...
+   fun:dlopen*
+   obj:/usr/lib*/nvidia/libGL.so*
+}
+{
+   alsa-lib-Leak
+   Memcheck:Leak
+   ...
+   fun:parse_defs
+}
+{
+   SDL-create_aux_windows-Leak
+   Memcheck:Leak
+   ...
+   fun:create_aux_windows
+}
+{
+   openal-init-Leak
+   Memcheck:Leak
+   ...
+   fun:snd1_dlobj_cache_add
+}
+{
+   dlclose-Leak
+   Memcheck:Leak
+   ...
+   fun:dlclose
+}
+
+# Memory leak in libselinux, should be fixed in current Fedora 12:
+# http://cvs.fedoraproject.org/viewvc/rpms/libselinux/F-12/libselinux-rhat.patch?r1=1.199&r2=1.200
+#{
+#   libselinux-Leak
+#   Memcheck:Leak
+#   ...
+#   fun:getdelim
+#   fun:init_lib
+#}