# This is a list of suppressions for Valgrind's Memcheck and Helgrind tools, used by
# valgame.sh and valcustom.sh.
# Many of these are probably out of date and can be removed; I've built these
# up over years.
# Also note some of the ones of the bottom look more like genuine bugs.

###############################################################################
# BORING STUFF
# These appear to be false alarms.

{
   sigaction uninitialised memory
   Memcheck:Param
   rt_sigaction(act->sa_mask)
   fun:__libc_sigaction
   fun:setup_exception_handler
   fun:LOWLEVEL_INIT
   fun:main
}
{
   x11_update start
   Memcheck:Addr1
   fun:x11_update
   fun:window_thread
   fun:start_thread
   fun:clone
}
{
   asound:setctl
   Memcheck:Param
   semctl(IPC_SET, arg.buf)
   fun:semctl@@GLIBC_2.2
   obj:/usr/lib/libasound.so.2.0.0
   fun:snd_pcm_dmix_open
   fun:_snd_pcm_dmix_open
}
{
   asound:overlao
   Memcheck:Overlap
   fun:memcpy
   fun:snd_pcm_area_copy
   fun:snd_pcm_areas_copy
   obj:/usr/lib/libasound.so.2.0.0
}
{
   asound:snd_timer_start
   Memcheck:Param
   ioctl(arg)
   fun:ioctl
   fun:snd_timer_start
   obj:/usr/lib/libasound.so.2.0.0
}
{
   asound:snd_timer_stop
   Memcheck:Param
   ioctl(arg)
   fun:ioctl
   fun:snd_timer_stop
   obj:/usr/lib/libasound.so.2.0.0
}
{
   ld.so uninitialised memory junk
   Memcheck:Cond
   ...
   fun:dl_main
   fun:_dl_sysdep_start
   fun:_dl_start
   obj:/lib/ld-2.11.1.so
}
{
   more ld.so uninitialised memory junk
   Memcheck:Cond
   ...
   fun:dl_open_worker
}
{
   SDL-X11 uninitialised memory (from XOpenDisplay)
   Memcheck:Param
   writev(vector[...])
   ...
   obj:/usr/lib/libxcb.so*
   obj:/usr/lib/libxcb.so*
   fun:xcb_writev
   fun:_XSend
   fun:_XReply
   fun:XSync
}
{
   SDL conditional jump on uninitialised memory
   Memcheck:Cond
   ...
   obj:/usr/lib/libSDL-1.2.so*
   fun:SDL_PumpEvents
}



#leaks
{
   asound:snd_config_* leak
   Memcheck:Leak
   ...
   fun:snd_config_*
}
{
   asound:_snd_pcm_*_open
   Memcheck:Leak
   ...
   fun:*snd_pcm_*_open
}
{
   SDL_AudioInit->asound leak
   Memcheck:Leak
   ...
   obj:/usr/lib/libasound.so.2.0.0
   ...
   fun:SDL_AudioInit
}
{
   asound so leaky
   Memcheck:Leak
   fun:*alloc
   obj:/usr/lib/libasound.so.2.0.0
   obj:/usr/lib/libasound.so.2.0.0
   obj:/usr/lib/libasound.so.2.0.0
   obj:/usr/lib/libasound.so.2.0.0
   obj:/usr/lib/libasound.so.2.0.0
   obj:/usr/lib/libasound.so.2.0.0
   obj:/usr/lib/libasound.so.2.0.0
   obj:/usr/lib/libasound.so.2.0.0
   obj:/usr/lib/libasound.so.2.0.0
   obj:/usr/lib/libasound.so.2.0.0
   obj:/usr/lib/libasound.so.2.0.0
}

{
   pulseaudio leaks
   Memcheck:Leak
   match-leak-kinds: definite
   fun:malloc
   fun:pa_xmalloc
}

{
   SDL-X11 leak
   Memcheck:Leak
   ...
   obj:/usr/lib/libX11.so*
   ...
   obj:/usr/lib/libSDL-1.2.so*
   fun:SDL_VideoInit
}

{
   fb_PrintStringEx init alloc
   Memcheck:Leak
   fun:malloc
   fun:fb_DevScrnInit_Screen
   fun:fb_DevScrnInit_NoOpen
   fun:fb_DevScrnInit_Write
   fun:fb_hFilePrintBufferEx
   fun:fb_PrintStringEx
}
{
   ld.so alloc
   Memcheck:Leak
   ...
   fun:dl_open_worker
}
{
   X11 init alloc
   Memcheck:Leak
   ...
   fun:XGetDefault
}
{
   SDL init alloc
   Memcheck:Leak
   fun:malloc
   obj:/usr/lib/libSDL-1.2.so*
   fun:SDL_InitSubSystem
   fun:SDL_Init
}
{
   fb_unix_hInit->tgetent alloc
   Memcheck:Leak
   ...
   fun:tgetent
   fun:fb_unix_hInit
   fun:fb_hInit
   fun:fb_hRtInit
}
{
   SDL-X11 alloc
   Memcheck:Leak
   ...
   obj:/usr/lib/libXext.so.6.4.0
   ...
   obj:/usr/lib/libSDL-1.2.so*
   fun:SDL_VideoInit
}

{
   fb_unix_hInit->console_resize alloc
   Memcheck:Leak
   fun:calloc
   fun:console_resize
   fun:fb_unix_hInit
}
{
   FB bug: hInitConsole file descriptor leak
   Memcheck:Leak
   fun:malloc
   fun:__fopen_internal
   fun:fopen64
   fun:fb_hInitConsole
}

{
   ld
   Memcheck:Cond
   obj:/lib/ld-*.so
}
{
   tgetent
   Memcheck:Cond
   obj:/lib/libc-*.so
}

# File leaks
{
   SDL2 dbus and udev sockets
   CoreError:FdNotClosed
   fun:socket
   ...
   fun:gfx_sdl2_init
}


###############################################################################
# INTERESTING STUFF
# Known or guessed to be genuine, e.g. due to bugs FB.

#definite leaks
{
   Any FB string resize (strings affixed with $ leak)
   Memcheck:Leak
   fun:malloc
   fun:fb_hStrRealloc
}
{
   Any FB string alloc (strings affixed with $ leak)
   Memcheck:Leak
   fun:malloc
   fun:fb_hStrRealloc
}

#reachable leaks
{
   Any FB array alloc
   Memcheck:Leak
   fun:calloc
   fun:fb_hArrayAlloc
   fun:hRedim
}
{
   Any FB array relloc
   Memcheck:Leak
   fun:realloc
   fun:fb_hArrayRealloc
   fun:hRedim
}
## These are reachable strings not due to the $ leak bug
{
   Init array of strings in main() (*_frame_captions)
   Memcheck:Leak
   fun:malloc
   fun:fb_hStrAlloc
   fun:fb_StrAssignEx
   fun:fb_StrInit
   fun:main
}
{
   FB string alloced in module ctor
   Memcheck:Leak
   fun:malloc
   fun:fb_hStrRealloc
   fun:fb_StrAssignEx
   fun:fb_StrAssign
   fun:fb_ctor__*
}

## These looks like a SDL_mixer MIDI/BAM playback bugs...
## (Hit by battles in test.rpg)

{
   SDL_mixer MIDI Conditional jump with uninitialised memory
   Memcheck:Cond
   obj:/usr/lib/libSDL_mixer-1.2.so*
   obj:/usr/lib/libSDL_mixer-1.2.so*
   obj:/usr/lib/libSDL_mixer-1.2.so*
   fun:Mix_LoadMUSType_RW
}
## Allocated from within Mix_LoadMUSType_RW
{
   SDL_mixer MIDI Use of uninitialised memory
   Memcheck:Value4
   obj:/usr/lib/libSDL_mixer-1.2.so*
}
## Allocated from within Mix_FadeInMusicPos
{
   SDL_mixer MIDI Write of uninitialised memory
   Memcheck:Addr2
   obj:/usr/lib/libSDL_mixer-1.2.so*
   obj:/usr/lib/libSDL_mixer-1.2.so*
   obj:/usr/lib/libSDL_mixer-1.2.so*
   obj:/usr/lib/libSDL_mixer-1.2.so*
   obj:/usr/lib/libSDL_mixer-1.2.so*
   fun:Mix_FadeInMusicPos
   fun:Mix_PlayMusic
}



###############################################################################
## Helgrind suppressions

# Pulseaudio crashes lots on my system, in any program using SDL_mixer,
# so there's a good chance these warnings are genuine bugs
{
   Pulseaudio is bugged
   Helgrind:Race
   obj:/usr/lib/pulseaudio/libpulsecommon*.so
}
{
   Pulseaudio is bugged
   Helgrind:Misc
   ...
   fun:pa_cond_signal
   fun:pa_threaded_mainloop_signal
   obj:/usr/lib/libpulse-simple.so*
}

# And the following specifically seems to be why PA crashes a lot when I resize the window
# (pa_context_set_name is called from SDL from SDL_WM_SetCaption)
{
   pa_context_set_name race bug
   Helgrind:Race
   ...
   fun:pa_context_set_name
}
# Conflicts with the above
{
   pa_context_set_name race bug
   Helgrind:Race
   ...
   fun:pa_mainloop_dispatch
   fun:pa_mainloop_iterate
}

# And this might be an SDL or SDL_mixer bug...
{
   SDL races
   Helgrind:Race
   obj:/usr/lib/libSDL-1.2.so*
   # SDL_LockAudio and SDL_UnlockAudio
   fun:SDL_*ockAudio
   #fun:Mix_VolumeMusic, fun:Mix_AllocateChannels, fun:Mix_ChannelFinished ...
}
{
   SDL races
   Helgrind:Race
   fun:SDL_PauseAudio
   fun:Mix_OpenAudio
}
{
   SDL races (conflicts with previous Mix_OpenAudio -> SDL_PauseAudio)
   Helgrind:Race
   obj:/usr/lib/libSDL-1.2.so.0.11.4
   ...
   fun:clone
}
