--- /dev/null
+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.
--- /dev/null
+#!/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 "$@"
--- /dev/null
+# 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
+#}