Skip to content

Commit

Permalink
Add tooling for running under Valgrind.
Browse files Browse the repository at this point in the history
SVN-Revision: 6622
  • Loading branch information
mattmccutchen committed Mar 22, 2010
1 parent 176ec92 commit 6552ecd
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tools/valgrind/README
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 7 additions & 0 deletions tools/valgrind/run
Original file line number Diff line number Diff line change
@@ -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 "$@"
79 changes: 79 additions & 0 deletions tools/valgrind/supertux.supp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Valgrind suppressions file for SuperTux
#
# Started by Matt McCutchen <[email protected]> 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
#}

0 comments on commit 6552ecd

Please sign in to comment.