Fix uninitialized atomic variables #10819

Merged
merged 1 commit into from Jul 14, 2017

Conversation

Projects
None yet
8 participants
Contributor

promag commented Jul 13, 2017

This PR fixes uninitialized atomic variables that caused some errors when running with valgrind:

==30439== Thread 5 bitcoin-scheduler:
==30439== Conditional jump or move depends on uninitialised value(s)
==30439==    at 0x6C8E0F: MaybeCompactWalletDB() (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x1863F3: std::_Function_handler<void (), void (*)()>::_M_invoke(std::_Any_data const&) (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x187D38: std::function<void ()>::operator()() const (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x5BEC84: Repeat(CScheduler*, std::function<void ()>, long) (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x5C3683: void boost::_bi::list3<boost::_bi::value<CScheduler*>, boost::_bi::value<std::function<void ()> >, boost::_bi::value<long> >::operator()<void (*)(CScheduler*, std::function<void ()>, long), boost::_bi::list0>(boost::_bi::type<void>, void (*&)(CScheduler*, std::function<void ()>, long), boost::_bi::list0&, int) (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x5C2ACF: boost::_bi::bind_t<void, void (*)(CScheduler*, std::function<void ()>, long), boost::_bi::list3<boost::_bi::value<CScheduler*>, boost::_bi::value<std::function<void ()> >, boost::_bi::value<long> > >::operator()() (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x5C1AAE: std::_Function_handler<void (), boost::_bi::bind_t<void, void (*)(CScheduler*, std::function<void ()>, long), boost::_bi::list3<boost::_bi::value<CScheduler*>, boost::_bi::value<std::function<void ()> >, boost::_bi::value<long> > > >::_M_invoke(std::_Any_data const&) (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x187D38: std::function<void ()>::operator()() const (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x5BE914: CScheduler::serviceQueue() (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x1A2239: boost::_mfi::mf0<void, CScheduler>::operator()(CScheduler*) const (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x19A233: void boost::_bi::list1<boost::_bi::value<CScheduler*> >::operator()<boost::_mfi::mf0<void, CScheduler>, boost::_bi::list0>(boost::_bi::type<void>, boost::_mfi::mf0<void, CScheduler>&, boost::_bi::list0&, int) (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x1907EB: boost::_bi::bind_t<void, boost::_mfi::mf0<void, CScheduler>, boost::_bi::list1<boost::_bi::value<CScheduler*> > >::operator()() (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==  Uninitialised value was created by a heap allocation
==30439==    at 0x4C2E19F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==30439==    by 0x664514: CWallet::CreateWalletFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x6673A5: CWallet::InitLoadWallet() (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x170E83: AppInitMain(boost::thread_group&, CScheduler&) (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x13E005: AppInit(int, char**) (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439==    by 0x13E6B6: main (in /home/joao/Projects/bitcoin/src/bitcoind)
==30439== 

==30439== HEAP SUMMARY:
==30439==     in use at exit: 2,384 bytes in 11 blocks
==30439==   total heap usage: 101,957 allocs, 101,946 frees, 69,306,991 bytes allocated
==30439== 
==30439== LEAK SUMMARY:
==30439==    definitely lost: 160 bytes in 1 blocks
==30439==    indirectly lost: 0 bytes in 0 blocks
==30439==      possibly lost: 0 bytes in 0 blocks
==30439==    still reachable: 2,224 bytes in 10 blocks
==30439==         suppressed: 0 bytes in 0 blocks
==30439== Rerun with --leak-check=full to see details of leaked memory
==30439== 
==30439== For counts of detected and suppressed errors, rerun with: -v
==30439== ERROR SUMMARY: 7 errors from 1 contexts (suppressed: 0 from 0)
Member

theuni commented Jul 13, 2017

utACK 4652791

Member

jonasschnelli commented Jul 14, 2017

Kicked travis (issue seems unrelated).
utACK 4652791

Contributor

paveljanik commented Jul 14, 2017

utACK 4652791

@gmaxwell

utACK

Contributor

TheBlueMatt commented Jul 14, 2017

utACK 4652791

@sipa sipa merged commit 4652791 into bitcoin:master Jul 14, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@sipa sipa added a commit that referenced this pull request Jul 14, 2017

@sipa sipa Merge #10819: Fix uninitialized atomic variables
4652791 Fix uninitialized atomic variables (João Barbosa)

Tree-SHA512: 5dd8924bc8743a094abdbc2464b835a0e7fd4948c102ea7c2251c6330bea5615c4459ba322a656fd6ac5f8d695b69d3709d225ddccef226cf8afc7de5e3d3019
b7d6623
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment