# Valgrind suppressions for stuff that we cannot control

# Memory leaks in standard tools (e.g. dash, tail, or sort)
{
   Memory leak in /bin tools
   Memcheck:Leak
   ...
   obj:/bin/*
}

{
   Memory leak in /usr/bin tools
   Memcheck:Leak
   ...
   obj:/usr/bin/*
}

# There's a constant leak of 56 bytes in the depths of libc which
# manifests, for example, when using backtrace()
{
   Memory leak in libc/dlopen with -pthread
   Memcheck:Leak
   fun:malloc
   fun:_dl_map_object_deps
   fun:dl_open_worker
   fun:_dl_catch_error
   fun:_dl_open
   fun:do_dlopen
   fun:_dl_catch_error
   fun:dlerror_run
   fun:__libc_dlopen_mode
}

# Another problem in glibc, where makecontext does not reset the EBP register,
# and backtrace goes too far when walking up the stack frames
{
   Invalid read in backtrace, called after makecontext
   Memcheck:Addr4
   fun:backtrace
   ...
   fun:makecontext
}

#There seems to be an issue with libc using an uninitialized value somewhere in dlopen
{
   Invalid read in dl_start
   Memcheck:Cond
   fun:index
   fun:expand_dynamic_string_token
   ...
   fun:_dl_start
}

# 72704 bytes leak from GCC >5.1 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64535
{
   Memory leak in dl_init
   Memcheck:Leak
   match-leak-kinds:reachable
   fun:malloc
   obj:/usr/lib/*/libstdc++.so.*
   fun:call_init.part.0
   ...
   fun:_dl_init
}

# SG3.13 : We will remove NetCards soon, so ignore these ones 
{
   Memory leak in Netcards
   Memcheck:Leak
   ...
   fun:sg_platf_new_router
   fun:STag_surfxml_router
   fun:surf_parse_lex
   ...
   fun:parse_platform_file
   fun:SIMIX_create_environment
}

{
   Memory leak in Netcards
   Memcheck:Leak
   match-leak-kinds: indirect
   fun:malloc
   fun:strdup
   fun:xbt_strdup
   ...
   fun:sg_platf_new_router
   fun:STag_surfxml_router
   fun:surf_parse_lex
   ...
   fun:parse_platform_file
   fun:SIMIX_create_environment
   fun:smpi_main
   fun:main
}

#Ignore leaks in SMPI sample codes
{
   Leaks in SMPI sample codes
   Memcheck:Leak
   match-leak-kinds: all
   fun:malloc
   fun:smpi_simulated_main_
}

# Memory leaks appearing to be in libcgraph.  They can be seen with the
# following simple program:
# ,----
# | #include <stdio.h>
# | #include <graphviz/cgraph.h>
# | int main(int argc, char *argv[])
# | {
# |     if (argc == 1) {
# |         printf("Usage: %s <dotfile>\n", argv[0]);
# |         return 1;
# |     }
# |     Agraph_t *g;
# |     FILE *inf = fopen(argv[1], "r");
# |     g = agread(inf, 0);
# |     fclose(inf);
# |     agclose(g);
# |     return 0;
# | }
# `----
{
   Memory leak in libcgraph (1/2)
   Memcheck:Leak
   fun:malloc
   ...
   obj:/usr/lib/libcgraph.so*
   fun:aaglex
   fun:aagparse
   fun:agconcat
}
{
   Memory leak in libcgraph (1/2)
   Memcheck:Leak
   fun:calloc
   ...
   obj:/usr/lib/libcgraph.so*
   fun:aagparse
   fun:agconcat
}
{
   Memory leak in libcgraph (2/2)
   Memcheck:Leak
   fun:malloc
   ...
   fun:agnode
   obj:/usr/lib/libcgraph.so*
   fun:aagparse
   fun:agconcat
}

# We're not interested by memory leaks in the Lua interpreter
{
   Memory leak in lua
   Memcheck:Leak
   ...
   fun:luaD_precall
}

# libunwind seems to be using msync poorly, thus triggering these
# https://github.com/JuliaLang/julia/issues/4533
{
   msync unwind
   Memcheck:Param
   msync(start)
   ...
   obj:*/libpthread*.so
   ...
}
