diff options
author | Mark Friedenbach <mark@monetize.io> | 2014-05-29 17:06:40 -0700 |
---|---|---|
committer | bitcoindev <bitcoindev@gnusha.org> | 2014-05-30 00:06:47 +0000 |
commit | cb11d14d77f88a4c43bfc79ead6046e41a8c5099 (patch) | |
tree | 139a19be7c5db2ebf616ccd6c1a54ac4b00005b6 | |
parent | 653165be239e8c8881fd5a22888aac88bf90570c (diff) | |
download | pi-bitcoindev-cb11d14d77f88a4c43bfc79ead6046e41a8c5099.tar.gz pi-bitcoindev-cb11d14d77f88a4c43bfc79ead6046e41a8c5099.zip |
Re: [Bitcoin-development] bitcoind minor bug in wallet and possible fix
-rw-r--r-- | 82/3d36c7abb9ee98531860a9f7174748a7232c32 | 200 |
1 files changed, 200 insertions, 0 deletions
diff --git a/82/3d36c7abb9ee98531860a9f7174748a7232c32 b/82/3d36c7abb9ee98531860a9f7174748a7232c32 new file mode 100644 index 000000000..8fe8d4704 --- /dev/null +++ b/82/3d36c7abb9ee98531860a9f7174748a7232c32 @@ -0,0 +1,200 @@ +Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] + helo=mx.sourceforge.net) + by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.76) + (envelope-from <mark@monetize.io>) id 1WqALP-0004PY-P7 + for bitcoin-development@lists.sourceforge.net; + Fri, 30 May 2014 00:06:47 +0000 +Received: from mail-qg0-f44.google.com ([209.85.192.44]) + by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) + (Exim 4.76) id 1WqALO-0005qi-8m + for bitcoin-development@lists.sourceforge.net; + Fri, 30 May 2014 00:06:47 +0000 +Received: by mail-qg0-f44.google.com with SMTP id i50so3300893qgf.3 + for <bitcoin-development@lists.sourceforge.net>; + Thu, 29 May 2014 17:06:40 -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=lQvUiJU4sLzUW3PW8WuJJvHNjX+95O3D5IyBFhJ/jFo=; + b=ga+BgLimaYVGJVj13yFNUfrghSXKaxpwlUdAbClJ1F6G5NZOiUsa/+nTc1SV3dC5qA + d3ptt/l140p1LtIB+9TTaI3Tg+rAsWbD2n+7cg/XrBaaJZu1qz3bRjjurmIyRKjX9ioc + bV8U39/F8oWswhtrKqg3NNjL6METXHnGWwPwJ4XZwCneJLL8tvyJVI8rrsHeqnUtLzxG + bz8xea4wAkO4gB1xwDdS1v3uWJGe5s0CLVkNDjbu03duR5EUmGEMMQsQlan1/ykvlpTL + 8NdhKG/5KrWxPNoLFzw7z63RZ/cYAjaHebMsDDzTEeCeXTGNMGI45/8Uc5MzexhlzA1H + ylgQ== +X-Gm-Message-State: ALoCoQm738Nm0WGtVNezLw1kF1I6g1A+v3gwUK7UjsiD5x/Rm8Km9CYS1ZdMIzUodW28br3pLRbh +MIME-Version: 1.0 +X-Received: by 10.140.84.83 with SMTP id k77mr14701530qgd.70.1401408400544; + Thu, 29 May 2014 17:06:40 -0700 (PDT) +Received: by 10.140.48.11 with HTTP; Thu, 29 May 2014 17:06:40 -0700 (PDT) +X-Originating-IP: [70.197.3.77] +Received: by 10.140.48.11 with HTTP; Thu, 29 May 2014 17:06:40 -0700 (PDT) +In-Reply-To: <CANFXpYMC2hYzFx5fPkqTv2LiCrtDny3yUV5u20ckK56zVjSpGA@mail.gmail.com> +References: <CANFXpYMC2hYzFx5fPkqTv2LiCrtDny3yUV5u20ckK56zVjSpGA@mail.gmail.com> +Date: Thu, 29 May 2014 17:06:40 -0700 +Message-ID: <CACh7GpHqCK=FFOO6C=mdHnqfCu5uZ34jf5ez6VDaSHimYnj5AA@mail.gmail.com> +From: Mark Friedenbach <mark@monetize.io> +To: Toshi Morita <toshi@peernova.com> +Content-Type: multipart/alternative; boundary=001a11c1317ce678bf04fa92d1ef +X-Spam-Score: 1.0 (+) +X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. + See http://spamassassin.org/tag/ for more details. + -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, + no trust [209.85.192.44 listed in list.dnswl.org] + 1.0 HTML_MESSAGE BODY: HTML included in message +X-Headers-End: 1WqALO-0005qi-8m +Cc: bitcoin-development@lists.sourceforge.net +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: <bitcoin-development.lists.sourceforge.net> +List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>, + <mailto:bitcoin-development-request@lists.sourceforge.net?subject=unsubscribe> +List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=bitcoin-development> +List-Post: <mailto:bitcoin-development@lists.sourceforge.net> +List-Help: <mailto:bitcoin-development-request@lists.sourceforge.net?subject=help> +List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/bitcoin-development>, + <mailto:bitcoin-development-request@lists.sourceforge.net?subject=subscribe> +X-List-Received-Date: Fri, 30 May 2014 00:06:47 -0000 + +--001a11c1317ce678bf04fa92d1ef +Content-Type: text/plain; charset=UTF-8 + +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-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 +> +> + +--001a11c1317ce678bf04fa92d1ef +Content-Type: text/html; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable + +<p dir=3D"ltr">Please make a pull request on github. It'll likely get m= +erged quickly.</p> +<div class=3D"gmail_quote">On May 29, 2014 5:04 PM, "Toshi Morita"= +; <<a href=3D"mailto:toshi@peernova.com">toshi@peernova.com</a>> wrot= +e:<br type=3D"attribution"><blockquote class=3D"gmail_quote" style=3D"margi= +n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> +<div dir=3D"ltr"><div><div>I ran bitcoind under valgrind and found a place = +where it references an uninitialized variable in some cases:<br><br>tm@tm-V= +irtualBox:~/bitcoind/bitcoin/src$ valgrind ./bitcoind<br>=3D=3D2337=3D=3D M= +emcheck, a memory error detector<br> + +=3D=3D2337=3D=3D Copyright (C) 2002-2012, and GNU GPL'd, by Julian Sewa= +rd et al.<br>=3D=3D2337=3D=3D Using Valgrind-3.8.1 and LibVEX; rerun with -= +h for copyright info<br>=3D=3D2337=3D=3D Command: ./bitcoind<br>=3D=3D2337= +=3D=3D<br>=3D=3D2337=3D=3D Conditional jump or move depends on uninitialise= +d value(s)<br> + +=3D=3D2337=3D=3D=C2=A0=C2=A0=C2=A0 at 0x319176: CWallet::LoadKeyMetadata(CP= +ubKey const&, CKeyMetadata const&) (wallet.cpp:110)<br>=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)<br> + +=3D=3D2337=3D=3D=C2=A0=C2=A0=C2=A0 by 0x3374F0: CWalletDB::LoadWallet(CWall= +et*) (walletdb.cpp:623)<br>=3D=3D2337=3D=3D=C2=A0=C2=A0=C2=A0 by 0x3218FD: = +CWallet::LoadWallet(bool&) (wallet.cpp:1485)<br>=3D=3D2337=3D=3D=C2=A0= +=C2=A0=C2=A0 by 0x157F16: AppInit2(boost::thread_group&) (init.cpp:958)= +<br> + +=3D=3D2337=3D=3D=C2=A0=C2=A0=C2=A0 by 0x140142: AppInit(int, char**) (bitco= +ind.cpp:143)<br>=3D=3D2337=3D=3D=C2=A0=C2=A0=C2=A0 by 0x13649E: main (bitco= +ind.cpp:180)<br>=3D=3D2337=3D=3D<br><br></div>The bug occurs here because n= +TimeFirstKey is not initialized when the wallet is instantiated:<br> + +<br>wallet.cpp:63<br>=C2=A0=C2=A0=C2=A0 if (!nTimeFirstKey || nCreationTime= + < nTimeFirstKey)<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nTimeFir= +stKey =3D nCreationTime;<br><br><br></div><div>I fixed it in my fork:<br><b= +r>diff --git a/src/wallet.h b/src/wallet.h<br>index 9607415..b78045f 100644= +<br> + +--- a/src/wallet.h<br>+++ b/src/wallet.h<br>@@ -163,6 +163,7 @@ public:<br>= +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nOrderPosNext =3D 0;<br>= +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nNextResend =3D 0;<br>=C2= +=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nLastResend =3D 0;<br>+=C2=A0= +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 nTimeFirstKey =3D 0; <br>=C2=A0=C2=A0= +=C2=A0=C2=A0 }<br><br></div><div> + +If this fix is ok please pull from my GitHub fork; username on GitHub is tm= +314159.<br><br>Toshi<br></div><div><br></div></div> +<br>-----------------------------------------------------------------------= +-------<br> +Time is money. Stop wasting it! Get your web API in 5 minutes.<br> +<a href=3D"http://www.restlet.com/download" target=3D"_blank">www.restlet.c= +om/download</a><br> +<a href=3D"http://p.sf.net/sfu/restlet" target=3D"_blank">http://p.sf.net/s= +fu/restlet</a><br>_______________________________________________<br> +Bitcoin-development mailing list<br> +<a href=3D"mailto:Bitcoin-development@lists.sourceforge.net">Bitcoin-develo= +pment@lists.sourceforge.net</a><br> +<a href=3D"https://lists.sourceforge.net/lists/listinfo/bitcoin-development= +" target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/bitcoin-de= +velopment</a><br> +<br></blockquote></div> + +--001a11c1317ce678bf04fa92d1ef-- + + |