# There are four kinds of suppressions in this file.
#
# 1. Third party stuff we have no control over.
#
# 2. Bugs involving Wine.
#
# 3. Chromium specific errors that are intentional unit test errors,
# or stuff that is somehow a false positive in our own code,
# or stuff that is so trivial it's not worth fixing.
#
# 4. Suppressions for real chromium bugs that are not yet fixed.
# These should all be in chromium's bug tracking system (but a few aren't yet).
# Periodically we should sweep this file and the bug tracker clean by
# running overnight and removing outdated bugs/suppressions.
#-----------------------------------------------------------------------

# 1. Third party stuff we have no control over.

# System bugs that aren't Wine's fault.
{
   suppress_nss_leak
   Memcheck:Leak
   fun:malloc
   obj:*
   fun:__nss_database_lookup
}
{
   bogus_Xcursor_Leak
   Memcheck:Leak
   fun:malloc
   obj:/usr/lib/libXcursor.so.1.0.2
}
{
   todo_suppress_libasound_leak
   Memcheck:Leak
   ...
   obj:/usr/lib*/libasound.so.2.0.0
}
{
   todo_suppress_libfontconfig_leak
   Memcheck:Leak
   fun:malloc
   obj:/usr/lib*/libfontconfig.so.1.*
}
# visual C++
{
   todo_visual_c_chkstk_2
   Memcheck:Addr4
   fun:_chkstk
}
{
   # Same leak exists in src/tools/valgrind/memcheck/suppressions.txt
   # with a mangled stack signature.
   Uninitialized value in deflate
   Memcheck:Cond
   ...
   fun:MOZ_Z_deflate
}

# 2. Bugs involving Wine

# These three happen if valgrind doesn't notice and handle speculative
# implementations of strchr/strlen/strcat properly.
{
   visual_c_ignore_strchr
   Memcheck:Cond
   fun:strchr
}
{
   visual_c_ignore_strlen
   Memcheck:Cond
   fun:strlen
}
{
   visual_c_ignore_strcat
   Memcheck:Cond
   fun:strcat
}

# Naming convention for Wine suppressions:
# # If we think it's solid:
# # suppress_wine_dirname__functionname[_moreifneeded]
# # If we aren't sure, change suppress to todo

# thread_detach() should clean this up??
{
   todo_wine_dlls_winex11drv__x11drv_init_thread_data_main
   Memcheck:Leak
   ...
   fun:RtlAllocateHeap
   fun:x11drv_init_thread_data
}
{
   todo_wine_dlls_winex11drv_XOpenDisplay
   Memcheck:Leak
   fun:malloc
   ...
   fun:xcb_connect
   fun:_XConnectXCB
   fun:XOpenDisplay
}
{
   todo_wine_dlls_winex11drv_XOpenDisplay_2
   Memcheck:Leak
   fun:malloc
   ...
   fun:xcb_get_extension_data
   fun:xcb_prefetch_maximum_request_length
   fun:xcb_get_maximum_request_length
   fun:XOpenDisplay
   fun:DllMain
}
{
   todo_suppress_alloc_module_leak
   Memcheck:Leak
   ...
   fun:RtlAllocateHeap
   fun:RtlCreateUnicodeString
   fun:alloc_module
}
{
   todo_suppress_dlopen_leak2
   Memcheck:Leak
   fun:*alloc
   ...
   fun:dl_open_worker
   fun:_dl_catch_error
   fun:_dl_open
   fun:dlopen_doit
   fun:_dl_catch_error
}
# ntdll/loader.c explicitly avoids freeing when .exe's exit at the moment
{
   todo_suppress_wine_alloc_module_leak
   Memcheck:Leak
   ...
   fun:RtlAllocateHeap
   fun:RtlCreateUnicodeString
   fun:alloc_module
}
# shell32 isn't freeing its imagelist cache on unload?
{
   wine_bug_20544
   Memcheck:Leak
   fun:malloc
   fun:XInitExtension
   fun:XextAddDisplay
   fun:*
   fun:XShmQueryVersion
   fun:X11DRV_CreateDIBSection
   fun:CreateDIBSection
   fun:ImageList_CreateImage
   fun:ImageList_Create
   fun:SIC_Initialize
   fun:DllMain
}
# winmm isn't freeing everything on unload?
{
   wine_bug_20545
   Memcheck:Leak
   ...
   fun:Rtl*AllocateHeap
   fun:MMDRV_InitPerType
   fun:MMDRV_Install
   fun:MMDRV_Init
}
# yet another leak on unload, seen on chromium's net http and ftp tests
{
   wine_bug_20549
   Memcheck:Leak
   fun:malloc
   ...
   fun:SECUR32_initSchannelSP
}
{
   # yet another gnutls leak?
   gnutls_leak_bug_2
   Memcheck:Leak
   fun:calloc
   ...
#   fun:_gnutls_hash_init         (commented out because sometimes this shows up without symbols)
#   fun:gnutls_handshake
   fun:schan_InitializeSecurityContextW
   fun:InitializeSecurityContextW
}
# leak on thread creation?
{
   wine_bug_20552
   Memcheck:Leak
   ...
   fun:RtlAllocateHeap
   fun:alloc_thread_tls
   fun:MODULE_DllThreadAttach
}
{
   wine_secur32_ignore_fork_helper_leak
   Memcheck:Leak
   ...
   fun:RtlAllocateHeap
   fun:fork_helper
   fun:SECUR32_initNTLMSP
}
{
   wine_bug_20548_ReadFile
   Memcheck:Leak
   ...
   fun:RtlAllocateHeap
   fun:NtReadFile
}
{
   wine_bug_20548_WS_shutdown
   Memcheck:Leak
   ...
   fun:RtlAllocateHeap
   fun:WS2_register_async_shutdown
   fun:WS_shutdown
}
{
   wine_bug_20654
   Memcheck:Leak
   ...
   fun:RtlAllocateHeap
   fun:get_full_path_helper
   fun:RtlGetFullPathName_U
}
{
   # This leak is expected - wine doesn't have a reliable way to free the default provider on exit.
   wine_bug_20679
   Memcheck:Leak
   ...
   fun:CRYPT_GetDefaultProvider
}
{
   # Benign window title leak?
   wine_bug_20692_wontfix
   Memcheck:Leak
   ...
   fun:DEFWND_SetText*
   ...
   fun:CreateWindow*
}
{
   wine_bug_21045
   Memcheck:Leak
   fun:RtlAllocateHeap
   fun:SECUR32_addPackages
   fun:SECUR32_initNegotiateSP
}

# 3. Chromium specific errors that are intentional unit test errors,
# or stuff that is somehow a false positive in our own code,
# or stuff that is so trivial it's not worth fixing.

{
   wine_bug_20551_as_seen_by_chromium
   Memcheck:Leak
   ...
   fun:RtlAllocateHeap
   ...
   fun:GlobalAlloc
   ...
   fun:Clipboard::WriteObjects
}
{
   suppress_chromium_crasher
   Memcheck:Addr1
   ...
   fun:*Test_Crasher*
}
{
   ignore_mozilla_errors
   Memcheck:Cond
   obj:*/ImporterTest/profile/mozcrt19.dll
}
{
   ignore_mozilla_errors2
   Memcheck:Cond
   obj:*/chrome/test/data/firefox3_nss/mozcrt19.dll
}
{
   ignore_gears_errors
   Memcheck:Addr4
   obj:*/gears.dll
}
{
   ignore_nss_decryptor_init_errors
   Memcheck:Leak
   fun:RtlAllocateHeap
   ...
   fun:NSSDecryptor::Init
}
# Not sure why Valgrind started to think everything happening in the
# usr1_handler is invalid. Can't seem to reproduce these locally.
# This happens in URLFetcherTest.SameThreadsTest.
{
   ignore_wine_ntdll_usr1_handler_a
   Memcheck:Addr1
   ...
   fun:usr1_handler
}
{
   ignore_wine_ntdll_usr1_handler_b
   Memcheck:Addr2
   ...
   fun:usr1_handler
}
{
   ignore_wine_ntdll_usr1_handler_c
   Memcheck:Addr4
   ...
   fun:usr1_handler
}
{
   # This occurs at the same time as the usr1_handler errors above.
   ignore_wine_ntdll_no_symbol
   Memcheck:Addr4
   obj:*ntdll.dll.so
}
{
   # mysterious leaks in rsaenh.dll.so, no symbols / incorrect symbols.
   ignore_wine_rsaenh_no_symbols
   Memcheck:Leak
   fun:RtlAllocateHeap
   obj:*rsaenh.dll.so

}
{
   # Maybe a leak in strtoi() ?? StringToInt() seems to be leak free.
   ignore_strtoi_leak
   Memcheck:Leak
   fun:RtlAllocateHeap
   ...
   fun:StringToInt
}
{
   # Maybe a leak in _strtoi64() ?? StringToInt64() seems to be leak free.
   ignore_strtoi64_leak
   Memcheck:Leak
   fun:RtlAllocateHeap
   ...
   fun:StringToInt64
}
{
   # A leak in _vsnprintf_s?
   ignore_vsnprintf_s
   Memcheck:Leak
   fun:RtlAllocateHeap
   ...
   fun:_vsnprintf_s
   fun:base::vsnprintf
   fun:vsnprintfT
}
{
   # A leak in _wfopen_s() ?? ReadFileToString() behaves correctly.
   ignore_wfopen_s_leak
   Memcheck:Leak
   fun:RtlAllocateHeap
   ...
   fun:_wfopen_s
   fun:file_util::ReadFileToString
   fun:FileReader::ReadFileOnBackgroundThread
}
{
   # Leaking an 8 byte Clipboard object in the test code.
   ignore_get_clipboard
   Memcheck:Leak
   fun:RtlAllocateHeap
   ...
   fun:operator new
   fun:TestViewsDelegate::GetClipboard
   fun:views::NativeTextfieldWin::OnCopy
}
{
   # mysterious leak in _calloc_crt. Bug in Wine perhaps?? Hard to reproduce.
   ignore_calloc_crt
   Memcheck:Leak
   fun:RtlAllocateHeap
   fun:win_heap_malloc
   fun:malloc
   fun:calloc
   fun:_calloc_impl
   fun:_calloc_crt
   STOP
}
{
   # Boy, oh, boy do we need a better way to deal with this.
   # See https://bugs.kde.org/show_bug.cgi?id=190660
   valgrind_bug_190660
   Memcheck:Addr4
   fun:strlen
}
{
   # Boy, oh, boy do we need a better way to deal with this.
   # See https://bugs.kde.org/show_bug.cgi?id=190660
   valgrind_bug_190660
   Memcheck:Addr4
   fun:strcmp
}
{
   # Boy, oh, boy do we need a better way to deal with this.
   # See https://bugs.kde.org/show_bug.cgi?id=190660
   valgrind_bug_190660
   Memcheck:Addr4
   fun:strchr
}
{
   # Boy, oh, boy do we need a better way to deal with this.
   # See https://bugs.kde.org/show_bug.cgi?id=190660
   valgrind_bug_190660
   Memcheck:Addr4
   fun:strcat
}
{
   # Boy, oh, boy do we need a better way to deal with this.
   # See https://bugs.kde.org/show_bug.cgi?id=190660
   valgrind_bug_190660
   Memcheck:Addr4
   fun:strncpy
}
{
   # Same leak exists in src/tools/valgrind/memcheck/suppressions.txt
   # with a mangled stack signature.
   intentional_ChromeThreadTest_NotReleasedIfTargetThreadNonExistent_Test_leak
   Memcheck:Leak
   ...
   fun:operator new
   fun:ChromeThreadTest_NotReleasedIfTargetThreadNonExistent_Test::TestBody
   fun:testing::Test::Run
}

# 4. Suppressions for real chromium bugs that are not yet fixed.
{
   # Same leak exists in src/tools/valgrind/memcheck/suppressions.txt
   # with a mangled stack signature.
   bug_15276
   Memcheck:Cond
   fun:cld::OctaHashV3Lookup4
   fun:cld::DoOctaScoreV3
   fun:ScoreQuadgrams
   fun:CompactLangDetImpl::DetectLanguageSummaryV25
   fun:CompactLangDet::DetectLanguage
}
{
   # Same leak exists in src/tools/valgrind/memcheck/suppressions.txt
   # with a mangled stack signature.
   bug_20653a
   Memcheck:Param
   write(buf)
   ...
   fun:sqlite3OsWrite
   fun:pager_write_pagelist
}
{
   # Same leak exists in src/tools/valgrind/memcheck/suppressions.txt
   # with a mangled stack signature.
   bug_20653b
   Memcheck:Param
   write(buf)
   ...
   fun:*Write
   fun:sqlite3OsWrite
   ...
   fun:pager_write
}
{
   bug_30547
   Memcheck:Leak
   ...
   fun:operator new
   fun:ImportantFileWriter::WriteNow
   fun:BookmarkStorage::SaveNow
   fun:BookmarkStorage::BookmarkModelDeleted
}
{
   bug_30614
   Memcheck:Cond
   fun:strncpy
   fun:AffixMgr::parse_affix
   ...
   fun:SpellCheck::InitializeHunspell
}
{
   bug_31640
   Memcheck:Leak
   fun:RtlAllocateHeap
   ...
   fun:xmlGetGlobalState
   fun:__xmlGenericError
   fun:ScopedXmlErrorFunc::ScopedXmlErrorFunc
   fun:UpdateManifest::Parse
}
{
   bug_31643
   Memcheck:Leak
   ...
   fun:operator new
   fun:browser_sync::UIModelWorker::DoWorkAndWaitUntilDone
   fun:Syncer::SyncShare
}
{
   bug_31644
   Memcheck:Leak
   ...
   fun:operator new
   fun:NewRunnableMethod<ExtensionsServiceBackend,void (__thiscall ExtensionsServiceBackend::*)(void)>
   fun:ExtensionsService::ClearProvidersForTesting
}
{
   bug_33424
   Memcheck:Leak
   ...
   fun:net::TCPClientSocketWin::Read
   fun:net::*::DoReadHeaders
   ...
   fun:net::*::OnIOComplete
}
{
   # This is a bit flaky, but it happens with both
   # FLAKY_FTPDirectoryListing_Test and FLAKY_FTPCacheLoginBoxCredentials_Test
   bug_33425
   Memcheck:Leak
   ...
   fun:net::TCPClientSocketWin::Read
   fun:net::FtpNetworkTransaction::DoCtrlRead
   fun:net::FtpNetworkTransaction::DoLoop
   fun:net::FtpNetworkTransaction::OnIOComplete
   fun:DispatchToMethod<net::FtpNetworkTransaction,void (__thiscall net::FtpNetworkTransaction::*)(int),int>
}
{
   # This is an invalid read/write that shows up sporadically.
   bug_33426
   Memcheck:Addr4
   fun:_free_base
   ...
   fun:std::basic_stringbuf<char,std::char_traits<char>,std::allocator<char> >::~basic_stringbuf<char,std::char_traits<char>,std::allocator<char> >
   fun:std::basic_stringstream<char,std::char_traits<char>,std::allocator<char> >::~basic_stringstream<char,std::char_traits<char>,std::allocator<char> >
   fun:std::basic_stringstream<char,std::char_traits<char>,std::allocator<char> >::`vbase destructor'
   fun:testing::internal::StrStreamToString
   fun:testing::Message::GetString
   fun:testing::AssertionResult::operator<<<enum net::LoadLog::EventPhase>
   ...
   fun:SSLClientSocketTest_ConnectMismatched_Test::TestBody
}
