From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1WqAPD-0006Yz-Od for bitcoin-development@lists.sourceforge.net; Fri, 30 May 2014 00:10:43 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of peernova.com designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; envelope-from=toshi@peernova.com; helo=mail-vc0-f179.google.com; Received: from mail-vc0-f179.google.com ([209.85.220.179]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1WqAPC-0005Ss-Du for bitcoin-development@lists.sourceforge.net; Fri, 30 May 2014 00:10:43 +0000 Received: by mail-vc0-f179.google.com with SMTP id im17so1263598vcb.38 for ; Thu, 29 May 2014 17:10:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=R1kAfYm85zTvx/nXT48rmDCOORdaZ7mtkwWPflZrcQw=; b=YJ0iuLNJq6rGsnJGQ7hJhsixQHcsZgyqMCfBKhpG9JzYdebbqGLMamuEWnJ1xSV3lr 6ds+STHGx7TRdp3TUr/ISXEgobGaJ4D8npEwen9hMKhtyO4CZFotov3dkxb+KyOujzo+ 9z0IBrPzVYLe9Sk3wfU4RBeohlWqXbLyM6AGsIzZobGz2AAwdwPspf20/fLg4QU7YDW0 JEygq6GeWAy+CpcJlsT+0sXEgjaDNcQgTlnYCDNoP6M00n96j2/OnhCOA7q4b7ZbeKy0 +XU07AM//h6wxbW3q6UqR8nBMBge+679zcmAPs8ue2a4gR6nUCN0RLeAu+l/lVvN+KAX 143g== X-Gm-Message-State: ALoCoQlamdpjCDQOpB1ZlH175WBmGL6VZGMIl+sunLRYUckNBZlEXW8gJumSgCd5WdUxM7gv8BD5 MIME-Version: 1.0 X-Received: by 10.52.53.69 with SMTP id z5mr8854368vdo.42.1401408636706; Thu, 29 May 2014 17:10:36 -0700 (PDT) Received: by 10.52.34.146 with HTTP; Thu, 29 May 2014 17:10:36 -0700 (PDT) In-Reply-To: References: Date: Thu, 29 May 2014 17:10:36 -0700 Message-ID: From: Toshi Morita To: Mark Friedenbach Content-Type: multipart/alternative; boundary=089e01183caef9f43604fa92dfde X-Spam-Score: -0.5 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record 1.0 HTML_MESSAGE BODY: HTML included in message X-Headers-End: 1WqAPC-0005Ss-Du Cc: bitcoin-development Subject: Re: [Bitcoin-development] bitcoind minor bug in wallet and possible fix X-BeenThere: bitcoin-development@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 May 2014 00:10:43 -0000 --089e01183caef9f43604fa92dfde Content-Type: text/plain; charset=UTF-8 Ok. Done. Toshi On Thu, May 29, 2014 at 5:06 PM, Mark Friedenbach wrote: > Please make a pull request on github. It'll likely get merged quickly. > On May 29, 2014 5:04 PM, "Toshi Morita" wrote: > >> I ran bitcoind under valgrind and found a place where it references an >> uninitialized variable in some cases: >> >> 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== >> >> The bug occurs here because nTimeFirstKey is not initialized when the >> wallet is instantiated: >> >> wallet.cpp:63 >> if (!nTimeFirstKey || nCreationTime < nTimeFirstKey) >> nTimeFirstKey = nCreationTime; >> >> >> I fixed it in my fork: >> >> diff --git a/src/wallet.h b/src/wallet.h >> index 9607415..b78045f 100644 >> --- a/src/wallet.h >> +++ b/src/wallet.h >> @@ -163,6 +163,7 @@ public: >> nOrderPosNext = 0; >> nNextResend = 0; >> nLastResend = 0; >> + nTimeFirstKey = 0; >> } >> >> If this fix is ok please pull from my GitHub fork; username on GitHub is >> tm314159. >> >> Toshi >> >> >> >> ------------------------------------------------------------------------------ >> Time is money. Stop wasting it! Get your web API in 5 minutes. >> www.restlet.com/download >> http://p.sf.net/sfu/restlet >> _______________________________________________ >> Bitcoin-development mailing list >> Bitcoin-development@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/bitcoin-development >> >> --089e01183caef9f43604fa92dfde Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Ok. Done.

Toshi



On Thu, Ma= y 29, 2014 at 5:06 PM, Mark Friedenbach <mark@monetize.io> wr= ote:

Please make a pull request on= github. It'll likely get merged quickly.

On May 29, 2014 5:04 PM, = "Toshi Morita" <toshi@peernova.com> wrote:
I ran bitcoind under valgrind and found a place = where it references an uninitialized variable in some cases:

tm@tm-V= irtualBox:~/bitcoind/bitcoin/src$ valgrind ./bitcoind
=3D=3D2337=3D=3D M= emcheck, a memory error detector
=3D=3D2337=3D=3D Copyright (C) 2002-2012, and GNU GPL'd, by Julian Sewa= rd et al.
=3D=3D2337=3D=3D Using Valgrind-3.8.1 and LibVEX; rerun with -= h for copyright info
=3D=3D2337=3D=3D Command: ./bitcoind
=3D=3D2337= =3D=3D
=3D=3D2337=3D=3D Conditional jump or move depends on uninitialise= d value(s)
=3D=3D2337=3D=3D=C2=A0=C2=A0=C2=A0 at 0x319176: CWallet::LoadKeyMetadata(CP= ubKey const&, CKeyMetadata const&) (wallet.cpp:110)
=3D=3D2337= =3D=3D=C2=A0=C2=A0=C2=A0 by 0x33645A: ReadKeyValue(CWallet*, CDataStream&am= p;, CDataStream&, CWalletScanState&, std::string&, std::string&= amp;) (walletdb.cpp:509)
=3D=3D2337=3D=3D=C2=A0=C2=A0=C2=A0 by 0x3374F0: CWalletDB::LoadWallet(CWall= et*) (walletdb.cpp:623)
=3D=3D2337=3D=3D=C2=A0=C2=A0=C2=A0 by 0x3218FD: = CWallet::LoadWallet(bool&) (wallet.cpp:1485)
=3D=3D2337=3D=3D=C2=A0= =C2=A0=C2=A0 by 0x157F16: AppInit2(boost::thread_group&) (init.cpp:958)=
=3D=3D2337=3D=3D=C2=A0=C2=A0=C2=A0 by 0x140142: AppInit(int, char**) (bitco= ind.cpp:143)
=3D=3D2337=3D=3D=C2=A0=C2=A0=C2=A0 by 0x13649E: main (bitco= ind.cpp:180)
=3D=3D2337=3D=3D

The bug occurs here because n= TimeFirstKey is not initialized when the wallet is instantiated:

wallet.cpp:63
=C2=A0=C2=A0=C2=A0 if (!nTimeFirstKey || nCreationTime= < nTimeFirstKey)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nTimeFir= stKey =3D nCreationTime;


I fixed it in my fork:
diff --git a/src/wallet.h b/src/wallet.h
index 9607415..b78045f 100644=
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -163,6 +163,7 @@ public:
= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nOrderPosNext =3D 0;
= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nNextResend =3D 0;
=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nLastResend =3D 0;
+=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nTimeFirstKey =3D 0;
=C2=A0=C2=A0= =C2=A0=C2=A0 }

If this fix is ok please pull from my GitHub fork; username on GitHub is tm= 314159.

Toshi


-----------------------------------------------------------= -------------------
Time is money. Stop wasting it! Get your web API in 5 minutes.
www.restlet.c= om/download
http://p.sf.net/s= fu/restlet
_______________________________________________
Bitcoin-development mailing list
Bitcoin-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bitcoin-de= velopment


--089e01183caef9f43604fa92dfde--