Skip to content

Instantly share code, notes, and snippets.

@vinnix
Last active December 26, 2017 02:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinnix/dd6eea7ce5d938c752166d3faebd7663 to your computer and use it in GitHub Desktop.
Save vinnix/dd6eea7ce5d938c752166d3faebd7663 to your computer and use it in GitHub Desktop.
Result of potential memleak using bitcoin-qt
$ ./bitcoin-qt --version
Bitcoin Core version v0.15.99.0-5180a86 (64-bit)
Copyright (C) 2009-2017 The Bitcoin Core developers
[vinnix@vnxsam bin]$ valgrind --leak-check=full --show-leak-kinds=all --leak-check=yes ./bitcoind
==2817== Memcheck, a memory error detector
==2817== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==2817== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==2817== Command: ./bitcoind
==2817==
==2817==
==2817== HEAP SUMMARY:
==2817== in use at exit: 3,200 bytes in 14 blocks
==2817== total heap usage: 8,603,254 allocs, 8,603,240 frees, 2,411,856,521 bytes allocated
==2817==
==2817== 8 bytes in 1 blocks are still reachable in loss record 1 of 14
==2817== at 0x4C29B83: malloc (vg_replace_malloc.c:299)
==2817== by 0x54D3829: boost::detail::get_once_per_thread_epoch() (in /usr/lib64/libboost_thread-mt.so.1.53.0)
==2817== by 0x5DAB54: void boost::call_once<void (*)()>(boost::once_flag&, void (*)()) (once.hpp:84)
==2817== by 0x5DA747: boost::call_once(void (*)(), boost::once_flag&) (once.hpp:29)
==2817== by 0x5D62FA: LogPrintStr(std::string const&) (util.cpp:353)
==2817== by 0x15EBC8: InitLogging() (init.cpp:810)
==2817== by 0x134E54: AppInit(int, char**) (bitcoind.cpp:130)
==2817== by 0x13565D: main (bitcoind.cpp:195)
==2817==
==2817== 8 bytes in 1 blocks are still reachable in loss record 2 of 14
==2817== at 0x4C2A1A3: operator new(unsigned long) (vg_replace_malloc.c:334)
==2817== by 0x77C1A6: leveldb::InitModule() (comparator.cc:73)
==2817== by 0x71D2E1F: pthread_once (in /usr/lib64/libpthread-2.17.so)
==2817== by 0x78468F: leveldb::port::InitOnce(int*, void (*)()) (port_posix.cc:53)
==2817== by 0x77C1FE: leveldb::BytewiseComparator() (comparator.cc:77)
==2817== by 0x783DAD: leveldb::Options::Options() (options.cc:13)
==2817== by 0x1C5E7A: CDBWrapper::CDBWrapper(boost::filesystem::path const&, unsigned long, bool, bool, bool) (dbwrapper.cpp:91)
==2817== by 0x3C5C50: CBlockTreeDB::CBlockTreeDB(unsigned long, bool, bool) (txdb.cpp:150)
==2817== by 0x1674A0: AppInitMain(boost::thread_group&, CScheduler&) (init.cpp:1418)
==2817== by 0x134F9D: AppInit(int, char**) (bitcoind.cpp:168)
==2817== by 0x13565D: main (bitcoind.cpp:195)
==2817==
==2817== 40 bytes in 1 blocks are still reachable in loss record 3 of 14
==2817== at 0x4C2A1A3: operator new(unsigned long) (vg_replace_malloc.c:334)
==2817== by 0x5D57D3: DebugPrintInit() (util.cpp:183)
==2817== by 0x5DABCB: void boost::call_once<void (*)()>(boost::once_flag&, void (*)()) (once.hpp:98)
==2817== by 0x5DA747: boost::call_once(void (*)(), boost::once_flag&) (once.hpp:29)
==2817== by 0x5D62FA: LogPrintStr(std::string const&) (util.cpp:353)
==2817== by 0x15EBC8: InitLogging() (init.cpp:810)
==2817== by 0x134E54: AppInit(int, char**) (bitcoind.cpp:130)
==2817== by 0x13565D: main (bitcoind.cpp:195)
==2817==
==2817== 40 bytes in 1 blocks are still reachable in loss record 4 of 14
==2817== at 0x4C29B83: malloc (vg_replace_malloc.c:299)
==2817== by 0x655AF51: ??? (in /usr/lib64/libevent_pthreads-2.0.so.5.1.9)
==2817== by 0x67707A2: event_global_setup_locks_ (in /usr/lib64/libevent-2.0.so.5.1.9)
==2817== by 0x655B11A: evthread_use_pthreads (in /usr/lib64/libevent_pthreads-2.0.so.5.1.9)
==2817== by 0x52D08D: InitHTTPServer() (httpserver.cpp:402)
==2817== by 0x15B308: AppInitServers(boost::thread_group&) (init.cpp:712)
==2817== by 0x165C78: AppInitMain(boost::thread_group&, CScheduler&) (init.cpp:1258)
==2817== by 0x134F9D: AppInit(int, char**) (bitcoind.cpp:168)
==2817== by 0x13565D: main (bitcoind.cpp:195)
==2817==
==2817== 40 bytes in 1 blocks are still reachable in loss record 5 of 14
==2817== at 0x4C29B83: malloc (vg_replace_malloc.c:299)
==2817== by 0x655AF51: ??? (in /usr/lib64/libevent_pthreads-2.0.so.5.1.9)
==2817== by 0x6782363: evsig_global_setup_locks_ (in /usr/lib64/libevent-2.0.so.5.1.9)
==2817== by 0x67707B5: event_global_setup_locks_ (in /usr/lib64/libevent-2.0.so.5.1.9)
==2817== by 0x655B11A: evthread_use_pthreads (in /usr/lib64/libevent_pthreads-2.0.so.5.1.9)
==2817== by 0x52D08D: InitHTTPServer() (httpserver.cpp:402)
==2817== by 0x15B308: AppInitServers(boost::thread_group&) (init.cpp:712)
==2817== by 0x165C78: AppInitMain(boost::thread_group&, CScheduler&) (init.cpp:1258)
==2817== by 0x134F9D: AppInit(int, char**) (bitcoind.cpp:168)
==2817== by 0x13565D: main (bitcoind.cpp:195)
==2817==
==2817== 40 bytes in 1 blocks are still reachable in loss record 6 of 14
==2817== at 0x4C29B83: malloc (vg_replace_malloc.c:299)
==2817== by 0x655AF51: ??? (in /usr/lib64/libevent_pthreads-2.0.so.5.1.9)
==2817== by 0x6780583: evutil_secure_rng_global_setup_locks_ (in /usr/lib64/libevent-2.0.so.5.1.9)
==2817== by 0x67707C0: event_global_setup_locks_ (in /usr/lib64/libevent-2.0.so.5.1.9)
==2817== by 0x655B11A: evthread_use_pthreads (in /usr/lib64/libevent_pthreads-2.0.so.5.1.9)
==2817== by 0x52D08D: InitHTTPServer() (httpserver.cpp:402)
==2817== by 0x15B308: AppInitServers(boost::thread_group&) (init.cpp:712)
==2817== by 0x165C78: AppInitMain(boost::thread_group&, CScheduler&) (init.cpp:1258)
==2817== by 0x134F9D: AppInit(int, char**) (bitcoind.cpp:168)
==2817== by 0x13565D: main (bitcoind.cpp:195)
==2817==
==2817== 64 bytes in 1 blocks are still reachable in loss record 7 of 14
==2817== at 0x4C2A1A3: operator new(unsigned long) (vg_replace_malloc.c:334)
==2817== by 0x782684: __gnu_cxx::new_allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem*>::allocate(unsigned long, void const*) (new_allocator.h:104)
==2817== by 0x7822DC: std::allocator_traits<std::allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem*> >::allocate(std::allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem*>&, unsigned long) (alloc_traits.h:436)
==2817== by 0x781E77: std::_Deque_base<leveldb::(anonymous namespace)::PosixEnv::BGItem, std::allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem> >::_M_allocate_map(unsigned long) (stl_deque.h:614)
==2817== by 0x781897: std::_Deque_base<leveldb::(anonymous namespace)::PosixEnv::BGItem, std::allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem> >::_M_initialize_map(unsigned long) (stl_deque.h:687)
==2817== by 0x781248: std::_Deque_base<leveldb::(anonymous namespace)::PosixEnv::BGItem, std::allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem> >::_Deque_base() (stl_deque.h:490)
==2817== by 0x780DA0: std::deque<leveldb::(anonymous namespace)::PosixEnv::BGItem, std::allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem> >::deque() (stl_deque.h:884)
==2817== by 0x7806E3: leveldb::(anonymous namespace)::PosixEnv::PosixEnv() (env_posix.cc:606)
==2817== by 0x780B97: leveldb::InitDefaultEnv() (env_posix.cc:679)
==2817== by 0x71D2E1F: pthread_once (in /usr/lib64/libpthread-2.17.so)
==2817== by 0x780CCB: leveldb::Env::Default() (env_posix.cc:692)
==2817== by 0x783DD4: leveldb::Options::Options() (options.cc:17)
==2817==
==2817== 152 bytes in 1 blocks are definitely lost in loss record 8 of 14
==2817== at 0x4C2B915: calloc (vg_replace_malloc.c:711)
==2817== by 0x676F398: event_base_once (in /usr/lib64/libevent-2.0.so.5.1.9)
==2817== by 0x52E8F8: StopHTTPServer() (httpserver.cpp:496)
==2817== by 0x14E528: Shutdown() (init.cpp:188)
==2817== by 0x134FE5: AppInit(int, char**) (bitcoind.cpp:183)
==2817== by 0x13565D: main (bitcoind.cpp:195)
==2817==
==2817== 160 bytes in 1 blocks are definitely lost in loss record 9 of 14
==2817== at 0x4C29B83: malloc (vg_replace_malloc.c:299)
==2817== by 0x5C2EAF4: __os_malloc (in /usr/lib64/libdb_cxx-4.8.so)
==2817== by 0x5BFC080: __env_alloc (in /usr/lib64/libdb_cxx-4.8.so)
==2817== by 0x5BB98F6: __lock_open (in /usr/lib64/libdb_cxx-4.8.so)
==2817== by 0x5C026A3: __env_attach_regions (in /usr/lib64/libdb_cxx-4.8.so)
==2817== by 0x5C02821: __env_open (in /usr/lib64/libdb_cxx-4.8.so)
==2817== by 0x5B1A969: DbEnv::open(char const*, unsigned int, int) (in /usr/lib64/libdb_cxx-4.8.so)
==2817== by 0x6EEB4B: CDBEnv::Open(boost::filesystem::path const&) (db.cpp:125)
==2817== by 0x6F0A1C: CDB::VerifyEnvironment(std::string const&, boost::filesystem::path const&, std::string&) (db.cpp:272)
==2817== by 0x6D25BB: CWalletDB::VerifyEnvironment(std::string const&, boost::filesystem::path const&, std::string&) (walletdb.cpp:811)
==2817== by 0x5FA22A: VerifyWallets() (init.cpp:230)
==2817== by 0x165CBF: AppInitMain(boost::thread_group&, CScheduler&) (init.cpp:1266)
==2817==
==2817== 376 bytes in 1 blocks are still reachable in loss record 10 of 14
==2817== at 0x4C2A1A3: operator new(unsigned long) (vg_replace_malloc.c:334)
==2817== by 0x780B8C: leveldb::InitDefaultEnv() (env_posix.cc:679)
==2817== by 0x71D2E1F: pthread_once (in /usr/lib64/libpthread-2.17.so)
==2817== by 0x780CCB: leveldb::Env::Default() (env_posix.cc:692)
==2817== by 0x783DD4: leveldb::Options::Options() (options.cc:17)
==2817== by 0x1C5E7A: CDBWrapper::CDBWrapper(boost::filesystem::path const&, unsigned long, bool, bool, bool) (dbwrapper.cpp:91)
==2817== by 0x3C5C50: CBlockTreeDB::CBlockTreeDB(unsigned long, bool, bool) (txdb.cpp:150)
==2817== by 0x1674A0: AppInitMain(boost::thread_group&, CScheduler&) (init.cpp:1418)
==2817== by 0x134F9D: AppInit(int, char**) (bitcoind.cpp:168)
==2817== by 0x13565D: main (bitcoind.cpp:195)
==2817==
==2817== 512 bytes in 1 blocks are still reachable in loss record 11 of 14
==2817== at 0x4C2A1A3: operator new(unsigned long) (vg_replace_malloc.c:334)
==2817== by 0x7827C8: __gnu_cxx::new_allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem>::allocate(unsigned long, void const*) (new_allocator.h:104)
==2817== by 0x782570: std::allocator_traits<std::allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem> >::allocate(std::allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem>&, unsigned long) (alloc_traits.h:436)
==2817== by 0x78209A: std::_Deque_base<leveldb::(anonymous namespace)::PosixEnv::BGItem, std::allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem> >::_M_allocate_node() (stl_deque.h:600)
==2817== by 0x781F03: std::_Deque_base<leveldb::(anonymous namespace)::PosixEnv::BGItem, std::allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem> >::_M_create_nodes(leveldb::(anonymous namespace)::PosixEnv::BGItem**, leveldb::(anonymous namespace)::PosixEnv::BGItem**) (stl_deque.h:725)
==2817== by 0x7818F0: std::_Deque_base<leveldb::(anonymous namespace)::PosixEnv::BGItem, std::allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem> >::_M_initialize_map(unsigned long) (stl_deque.h:699)
==2817== by 0x781248: std::_Deque_base<leveldb::(anonymous namespace)::PosixEnv::BGItem, std::allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem> >::_Deque_base() (stl_deque.h:490)
==2817== by 0x780DA0: std::deque<leveldb::(anonymous namespace)::PosixEnv::BGItem, std::allocator<leveldb::(anonymous namespace)::PosixEnv::BGItem> >::deque() (stl_deque.h:884)
==2817== by 0x7806E3: leveldb::(anonymous namespace)::PosixEnv::PosixEnv() (env_posix.cc:606)
==2817== by 0x780B97: leveldb::InitDefaultEnv() (env_posix.cc:679)
==2817== by 0x71D2E1F: pthread_once (in /usr/lib64/libpthread-2.17.so)
==2817== by 0x780CCB: leveldb::Env::Default() (env_posix.cc:692)
==2817==
==2817== 568 bytes in 1 blocks are still reachable in loss record 12 of 14
==2817== at 0x4C29B83: malloc (vg_replace_malloc.c:299)
==2817== by 0x744D58C: __fopen_internal (in /usr/lib64/libc-2.17.so)
==2817== by 0x5C5C53: fsbridge::fopen(boost::filesystem::path const&, char const*) (fs.cpp:7)
==2817== by 0x5D5A9E: OpenDebugLog() (util.cpp:206)
==2817== by 0x16559E: AppInitMain(boost::thread_group&, CScheduler&) (init.cpp:1214)
==2817== by 0x134F9D: AppInit(int, char**) (bitcoind.cpp:168)
==2817== by 0x13565D: main (bitcoind.cpp:195)
==2817==
==2817== 568 bytes in 1 blocks are still reachable in loss record 13 of 14
==2817== at 0x4C29B83: malloc (vg_replace_malloc.c:299)
==2817== by 0x744D58C: __fopen_internal (in /usr/lib64/libc-2.17.so)
==2817== by 0x5C5C53: fsbridge::fopen(boost::filesystem::path const&, char const*) (fs.cpp:7)
==2817== by 0x6EEA63: CDBEnv::Open(boost::filesystem::path const&) (db.cpp:121)
==2817== by 0x6F0A1C: CDB::VerifyEnvironment(std::string const&, boost::filesystem::path const&, std::string&) (db.cpp:272)
==2817== by 0x6D25BB: CWalletDB::VerifyEnvironment(std::string const&, boost::filesystem::path const&, std::string&) (walletdb.cpp:811)
==2817== by 0x5FA22A: VerifyWallets() (init.cpp:230)
==2817== by 0x165CBF: AppInitMain(boost::thread_group&, CScheduler&) (init.cpp:1266)
==2817== by 0x134F9D: AppInit(int, char**) (bitcoind.cpp:168)
==2817== by 0x13565D: main (bitcoind.cpp:195)
==2817==
==2817== 624 bytes in 1 blocks are possibly lost in loss record 14 of 14
==2817== at 0x4C2B915: calloc (vg_replace_malloc.c:711)
==2817== by 0x4011F04: _dl_allocate_tls (in /usr/lib64/ld-2.17.so)
==2817== by 0x71CE9C0: pthread_create@@GLIBC_2.2.5 (in /usr/lib64/libpthread-2.17.so)
==2817== by 0x780894: leveldb::(anonymous namespace)::PosixEnv::Schedule(void (*)(void*), void*) (env_posix.cc:617)
==2817== by 0x7485EB: leveldb::DBImpl::MaybeScheduleCompaction() (db_impl.cc:659)
==2817== by 0x74AE73: leveldb::DBImpl::Get(leveldb::ReadOptions const&, leveldb::Slice const&, std::string*) (db_impl.cc:1148)
==2817== by 0x3CC047: bool CDBWrapper::Read<std::pair<char, int>, CBlockFileInfo>(std::pair<char, int> const&, CBlockFileInfo&) const (dbwrapper.h:233)
==2817== by 0x3C5D3D: CBlockTreeDB::ReadBlockFileInfo(int, CBlockFileInfo&) (txdb.cpp:154)
==2817== by 0x43F339: LoadBlockIndexDB(CChainParams const&) (validation.cpp:3719)
==2817== by 0x44475D: LoadBlockIndex(CChainParams const&) (validation.cpp:4133)
==2817== by 0x167504: AppInitMain(boost::thread_group&, CScheduler&) (init.cpp:1434)
==2817== by 0x134F9D: AppInit(int, char**) (bitcoind.cpp:168)
==2817==
==2817== LEAK SUMMARY:
==2817== definitely lost: 312 bytes in 2 blocks
==2817== indirectly lost: 0 bytes in 0 blocks
==2817== possibly lost: 624 bytes in 1 blocks
==2817== still reachable: 2,264 bytes in 11 blocks
==2817== suppressed: 0 bytes in 0 blocks
==2817==
==2817== For counts of detected and suppressed errors, rerun with: -v
==2817== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)
[vinnix@vnxsam bin]$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment