LearnBitcoin

Bitcoin Dev Archive 2014

Another uninitialized memory problem

5 messages, 2 to 3 Jun 2014. Started by Toshi Morita.

Toshi Morita (2), Jeff Garzik (2), Wladimir J. van der Laan

Permalink Original thread on gnusha.org

Toshi Morita permalink original

I'm seeing another uninitialized memory problem in bitcoind using valgrind:

tm@tm-VirtualBox:~/bitcoind/bitcoin/src$ valgrind ./bitcoind ==2337== Memcheck, a memory error detector ==2337== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. ==2337== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info ==2337== Command: ./bitcoind ==2337== ==2337== Conditional jump or move depends on uninitialised value(s) ==2337== at 0x319176: CWallet::LoadKeyMetadata(CPubKey const&, CKeyMetadata const&) (wallet.cpp:110) ==2337== by 0x33645A: ReadKeyValue(CWallet*, CDataStream&, CDataStream&, CWalletScanState&, std::string&, std::string&) (walletdb.cpp:509) ==2337== by 0x3374F0: CWalletDB::LoadWallet(CWallet*) (walletdb.cpp:623) ==2337== by 0x3218FD: CWallet::LoadWallet(bool&) (wallet.cpp:1485) ==2337== by 0x157F16: AppInit2(boost::thread_group&) (init.cpp:958) ==2337== by 0x140142: AppInit(int, char**) (bitcoind.cpp:143) ==2337== by 0x13649E: main (bitcoind.cpp:180) ==2337==

Wladimir J. van der Laan in reply to Toshi Morita permalink original

On Mon, Jun 2, 2014 at 10:01 PM, Toshi Morita <toshi@peernova•com> wrote:

Quoted text (1 line)
> I'm seeing another uninitialized memory problem in bitcoind using valgrind:

Thanks for the report.

Which version/commit id of bitcoind?

Wladimir

Jeff Garzik in reply to Toshi Morita permalink original

I think I see the problem.

On Mon, Jun 2, 2014 at 4:01 PM, Toshi Morita <toshi@peernova•com> wrote:

Quoted text (32 lines)
> I'm seeing another uninitialized memory problem in bitcoind using valgrind:
>
> tm@tm-VirtualBox:~/bitcoind/bitcoin/src$ valgrind ./bitcoind
> ==2337== Memcheck, a memory error detector
> ==2337== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
> ==2337== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
> ==2337== Command: ./bitcoind
> ==2337==
> ==2337== Conditional jump or move depends on uninitialised value(s)
> ==2337==    at 0x319176: CWallet::LoadKeyMetadata(CPubKey const&,
> CKeyMetadata const&) (wallet.cpp:110)
> ==2337==    by 0x33645A: ReadKeyValue(CWallet*, CDataStream&, CDataStream&,
> CWalletScanState&, std::string&, std::string&) (walletdb.cpp:509)
> ==2337==    by 0x3374F0: CWalletDB::LoadWallet(CWallet*) (walletdb.cpp:623)
> ==2337==    by 0x3218FD: CWallet::LoadWallet(bool&) (wallet.cpp:1485)
> ==2337==    by 0x157F16: AppInit2(boost::thread_group&) (init.cpp:958)
> ==2337==    by 0x140142: AppInit(int, char**) (bitcoind.cpp:143)
> ==2337==    by 0x13649E: main (bitcoind.cpp:180)
> ==2337==
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/NeoTech
> _______________________________________________
> Bitcoin-development mailing list
> Bitcoin-development@lists•sourceforge•net
> https://lists.sourceforge.net/lists/listinfo/bitcoin-development
>
Toshi Morita in reply to Jeff Garzik permalink original

I looked at this a bit more yesterday, and it looks like both sides of the comparison were uninitialized, and I fixed one side, but the other side has the same problem.

I'll try to investigate further this afternoon once I get out of meetings/meetings prep.

Toshi

On Tue, Jun 3, 2014 at 9:43 AM, Jeff Garzik <jgarzik@bitpay•com> wrote:

Quoted text (50 lines)
> I think I see the problem.
>
>
> On Mon, Jun 2, 2014 at 4:01 PM, Toshi Morita <toshi@peernova•com> wrote:
> > I'm seeing another uninitialized memory problem in bitcoind using
> valgrind:
> >
> > tm@tm-VirtualBox:~/bitcoind/bitcoin/src$ valgrind ./bitcoind
> > ==2337== Memcheck, a memory error detector
> > ==2337== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
> > ==2337== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright
> info
> > ==2337== Command: ./bitcoind
> > ==2337==
> > ==2337== Conditional jump or move depends on uninitialised value(s)
> > ==2337==    at 0x319176: CWallet::LoadKeyMetadata(CPubKey const&,
> > CKeyMetadata const&) (wallet.cpp:110)
> > ==2337==    by 0x33645A: ReadKeyValue(CWallet*, CDataStream&,
> CDataStream&,
> > CWalletScanState&, std::string&, std::string&) (walletdb.cpp:509)
> > ==2337==    by 0x3374F0: CWalletDB::LoadWallet(CWallet*)
> (walletdb.cpp:623)
> > ==2337==    by 0x3218FD: CWallet::LoadWallet(bool&) (wallet.cpp:1485)
> > ==2337==    by 0x157F16: AppInit2(boost::thread_group&) (init.cpp:958)
> > ==2337==    by 0x140142: AppInit(int, char**) (bitcoind.cpp:143)
> > ==2337==    by 0x13649E: main (bitcoind.cpp:180)
> > ==2337==
> >
> >
> >
> ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and
> their
> > applications. Written by three acclaimed leaders in the field,
> > this first edition is now available. Download your free book today!
> > http://p.sf.net/sfu/NeoTech
> > _______________________________________________
> > Bitcoin-development mailing list
> > Bitcoin-development@lists•sourceforge•net
> > https://lists.sourceforge.net/lists/listinfo/bitcoin-development
> >
>
>
>
> --
> Jeff Garzik
> Bitcoin core developer and open source evangelist
> BitPay, Inc.      https://bitpay.com/
>
Jeff Garzik in reply to Toshi Morita permalink original

Does this fix it? https://github.com/bitcoin/bitcoin/pull/4282

On Tue, Jun 3, 2014 at 12:47 PM, Toshi Morita <toshi@peernova•com> wrote:

Quoted text (64 lines)
> I looked at this a bit more yesterday, and it looks like both sides of the
> comparison were uninitialized, and I fixed one side, but the other side has
> the same problem.
>
> I'll try to investigate further this afternoon once I get out of
> meetings/meetings prep.
>
> Toshi
>
>
>
> On Tue, Jun 3, 2014 at 9:43 AM, Jeff Garzik <jgarzik@bitpay•com> wrote:
>>
>> I think I see the problem.
>>
>>
>> On Mon, Jun 2, 2014 at 4:01 PM, Toshi Morita <toshi@peernova•com> wrote:
>> > I'm seeing another uninitialized memory problem in bitcoind using
>> > valgrind:
>> >
>> > tm@tm-VirtualBox:~/bitcoind/bitcoin/src$ valgrind ./bitcoind
>> > ==2337== Memcheck, a memory error detector
>> > ==2337== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
>> > ==2337== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright
>> > info
>> > ==2337== Command: ./bitcoind
>> > ==2337==
>> > ==2337== Conditional jump or move depends on uninitialised value(s)
>> > ==2337==    at 0x319176: CWallet::LoadKeyMetadata(CPubKey const&,
>> > CKeyMetadata const&) (wallet.cpp:110)
>> > ==2337==    by 0x33645A: ReadKeyValue(CWallet*, CDataStream&,
>> > CDataStream&,
>> > CWalletScanState&, std::string&, std::string&) (walletdb.cpp:509)
>> > ==2337==    by 0x3374F0: CWalletDB::LoadWallet(CWallet*)
>> > (walletdb.cpp:623)
>> > ==2337==    by 0x3218FD: CWallet::LoadWallet(bool&) (wallet.cpp:1485)
>> > ==2337==    by 0x157F16: AppInit2(boost::thread_group&) (init.cpp:958)
>> > ==2337==    by 0x140142: AppInit(int, char**) (bitcoind.cpp:143)
>> > ==2337==    by 0x13649E: main (bitcoind.cpp:180)
>> > ==2337==
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Learn Graph Databases - Download FREE O'Reilly Book
>> > "Graph Databases" is the definitive new guide to graph databases and
>> > their
>> > applications. Written by three acclaimed leaders in the field,
>> > this first edition is now available. Download your free book today!
>> > http://p.sf.net/sfu/NeoTech
>> > _______________________________________________
>> > Bitcoin-development mailing list
>> > Bitcoin-development@lists•sourceforge•net
>> > https://lists.sourceforge.net/lists/listinfo/bitcoin-development
>> >
>>
>>
>>
>> --
>> Jeff Garzik
>> Bitcoin core developer and open source evangelist
>> BitPay, Inc.      https://bitpay.com/
>
>