novitski / bitcoinj

Automatically exported from code.google.com/p/bitcoinj
Apache License 2.0
0 stars 0 forks source link

StackOverflowError in PeerGroup when a peer disconnects #507

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I occasionally get a StackOverflow. It seems to happen randomly, but always 
starts with a peers death and end in computeYearAndDay().

This is happening on the 0.11-SNAPSHOT. Could 
https://code.google.com/p/bitcoinj/issues/detail?id=391 be related?

Stacktrace:

java.lang.StackOverflowError
at java.util.GregorianCalendar.computeYearAndDay(GregorianCalendar.java:798)
at java.util.GregorianCalendar.fullFieldsCalc(GregorianCalendar.java:480)
at java.util.GregorianCalendar.computeFields(GregorianCalendar.java:573)
at java.util.Calendar.complete(Calendar.java:830)
at java.util.Calendar.setTimeInMillis(Calendar.java:1195)
at java.util.Calendar.setTime(Calendar.java:1183)
at java.text.SimpleDateFormat.formatImpl(SimpleDateFormat.java:518)
at java.text.SimpleDateFormat.format(SimpleDateFormat.java:818)
at java.text.DateFormat.format(DateFormat.java:307)
at ch.qos.logback.core.util.CachingDateFormatter.format(Unknown Source)
at ch.qos.logback.classic.pattern.DateConverter.convert(Unknown Source)
at ch.qos.logback.core.pattern.FormattingConverter.write(Unknown Source)
at ch.qos.logback.core.pattern.PatternLayoutBase.writeLoopOnConverters(Unknown 
Source)
at ch.qos.logback.classic.PatternLayout.doLayout(Unknown Source)
at ch.qos.logback.core.encoder.LayoutWrappingEncoder.doEncode(Unknown Source)
at ch.qos.logback.core.OutputStreamAppender.writeOut(Unknown Source)
at ch.qos.logback.core.FileAppender.writeOut(Unknown Source)
at ch.qos.logback.core.OutputStreamAppender.subAppend(Unknown Source)
at ch.qos.logback.core.FileAppender.subAppend(Unknown Source)
at ch.qos.logback.core.rolling.RollingFileAppender.subAppend(Unknown Source)
at ch.qos.logback.core.OutputStreamAppender.append(Unknown Source)
at ch.qos.logback.core.UnsynchronizedAppenderBase.doAppend(Unknown Source)
at ch.qos.logback.core.spi.AppenderAttachableImpl.appendLoopOnAppenders(Unknown 
Source)
at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend$4c03a5e5(Unknown 
Source)
at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus$4c03a5e5(Unknown Source)
at ch.qos.logback.classic.Logger.error(Unknown Source)
at 
com.google.bitcoin.net.NioClientManager.openConnection(NioClientManager.java:146
)
at com.google.bitcoin.core.PeerGroup.connectTo$12bf8b2a(PeerGroup.java:725)
at com.google.bitcoin.core.PeerGroup.connectToAnyPeer(PeerGroup.java:522)
at com.google.bitcoin.core.PeerGroup.handlePeerDeath(PeerGroup.java:1004)

=== Repeated 66 more times ===

at com.google.bitcoin.core.PeerGroup.connectTo$12bf8b2a(PeerGroup.java:728)
at com.google.bitcoin.core.PeerGroup.connectToAnyPeer(PeerGroup.java:522)
at com.google.bitcoin.core.PeerGroup.handlePeerDeath(PeerGroup.java:1004)
at 
com.google.bitcoin.core.PeerGroup$PeerStartupListener.onPeerDisconnected(PeerGro
up.java:157)
at com.google.bitcoin.core.Peer$1.run(Peer.java:259)
at com.google.bitcoin.utils.Threading$2.execute(Threading.java:109)
at com.google.bitcoin.core.Peer.connectionClosed(Peer.java:256)
at 
com.google.bitcoin.net.ConnectionHandler.closeConnection(ConnectionHandler.java:
172)
at 
com.google.bitcoin.net.ConnectionHandler.handleKey(ConnectionHandler.java:199)
at com.google.bitcoin.net.NioClientManager.run(NioClientManager.java:124)
at 
com.google.common.util.concurrent.AbstractExecutionThreadService$1$1.run(Abstrac
tExecutionThreadService.java:52)
at java.lang.Thread.run(Thread.java:841)

Original issue reported on code.google.com by max.kell...@googlemail.com on 2 Jan 2014 at 6:02

GoogleCodeExporter commented 9 years ago
Is that the latest git master code? Do you have logs?

Original comment by hearn@google.com on 2 Jan 2014 at 7:23

GoogleCodeExporter commented 9 years ago
Yes, the latest git master code. Sorry for not providing logs. I jsut checked 
the logs of different times of the crash and it boils down to the network going 
down while being connected to peers. It happened on an Android app if that is 
important.

Here is the interesting snippet of the log:

//Ususal Transaction announcments...
19:19:23.250 [NioClientManager] ConnectionHandler - Error handling 
SelectionKey: recvfrom failed: ETIMEDOUT (Connection timed out)
19:19:23.251 [NioClientManager] PeerGroup - [98.164.13.253]:8333: Peer died
19:19:23.253 [NioClientManager] NioClientManager - Could not connect to 
/173.77.168.159:8333
19:19:23.253 [NioClientManager] PeerGroup - Failed to connect to 
/173.77.168.159:8333: java.net.ConnectException: failed to connect to 
/173.77.168.159 (port 8333): connect failed: ENETUNREACH (Network is 
unreachable)
19:19:23.253 [NioClientManager] PeerGroup - [173.77.168.159]:8333: Peer died

Last three lines repeat for every peer (until SO) I got from the PeerDiscovery 
until the log begins with the app startup again. This correlation is with all 
the occasions of the StackOverflow so far.

Original comment by max.kell...@googlemail.com on 2 Jan 2014 at 7:56

GoogleCodeExporter commented 9 years ago
handlePeerDeath does not call connectToAnyPeer after my recent change to the 
way PeerGroup works, so this couldn't be git master.

Please try the latest.

Original comment by c1.devra...@niftybox.net on 2 Jan 2014 at 8:15

GoogleCodeExporter commented 9 years ago
Wow, now this is somewhat emberassing. I just checked my git history and 
oversaw the last 3 commits. Sorry to cause you trouble here, I'm a git newbie :/
I added the last changes and will watch out if this happens again, which I 
suppose won't. Thanks so much for your hard work here!

Original comment by max.kell...@googlemail.com on 2 Jan 2014 at 9:31

GoogleCodeExporter commented 9 years ago
Glad to be of help. :)

Original comment by c1.devra...@niftybox.net on 2 Jan 2014 at 10:04

GoogleCodeExporter commented 9 years ago
I think we can forgive you for being 3 commits behind ;) You just got 
unlucky/lucky that Miron fixed this issue (by adding an exponential backoff 
feature) very recently. Going to close this as fixed.

Original comment by hearn@google.com on 5 Jan 2014 at 2:20

GoogleCodeExporter commented 9 years ago
Is this likely to also be an issue for 0.10?

Original comment by andreas....@gmail.com on 5 Jan 2014 at 3:11

GoogleCodeExporter commented 9 years ago
Not sure. It depends on the details of how you respond to the network going 
down and how the OS exposes that. If you aren't getting stack overflow crash 
reports from your app then probably the answer is "no".

Original comment by hearn@google.com on 5 Jan 2014 at 4:01