novitski / bitcoinj

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

Deadlock in PeerGroup - 1070 / Peer - 179 #349

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Using commit 0.7 25387d6 got this deadlock.

Found one Java-level deadlock:
=============================
"New I/O client worker #1-14":
  waiting to lock monitor 0x0000000006a19060 (object 0x0000000740442940, a com.google.bitcoin.core.PeerGroup),
  which is held by "New I/O client worker #1-4"
"New I/O client worker #1-4":
  waiting to lock monitor 0x0000000009140bf8 (object 0x000000074e16a338, a com.google.bitcoin.core.Peer),
  which is held by "New I/O client worker #1-14"

"New I/O client worker #1-14":
    at com.google.bitcoin.core.PeerGroup$10$1.onConfidenceChanged(PeerGroup.java:1070)
    - waiting to lock <0x0000000740442940> (a com.google.bitcoin.core.PeerGroup)
    at com.google.bitcoin.core.TransactionConfidence$1.invoke(TransactionConfidence.java:411)
    at com.google.bitcoin.core.TransactionConfidence$1.invoke(TransactionConfidence.java:1)
    at com.google.bitcoin.utils.EventListenerInvoker.invoke(EventListenerInvoker.java:47)
    - locked <0x0000000749dcdf60> (a com.google.bitcoin.core.PeerGroup$10$1)
    - locked <0x0000000749dcdf30> (a java.util.ArrayList)
    at com.google.bitcoin.core.TransactionConfidence.runListeners(TransactionConfidence.java:408)
    at com.google.bitcoin.core.TransactionConfidence.setConfidenceType(TransactionConfidence.java:233)
    - locked <0x0000000749dcdea0> (a com.google.bitcoin.core.TransactionConfidence)
    at com.google.bitcoin.core.TransactionConfidence.setAppearedAtChainHeight(TransactionConfidence.java:214)
    - locked <0x0000000749dcdea0> (a com.google.bitcoin.core.TransactionConfidence)
    at com.google.bitcoin.core.Transaction.setBlockAppearance(Transaction.java:260)
    at com.google.bitcoin.core.Wallet.receive(Wallet.java:992)
    - locked <0x0000000740263c00> (a com.google.bitcoin.core.Wallet)
    at com.google.bitcoin.core.Wallet.receiveFromBlock(Wallet.java:718)
    - locked <0x0000000740263c00> (a com.google.bitcoin.core.Wallet)
    at com.google.bitcoin.core.AbstractBlockChain.sendTransactionsToListener(AbstractBlockChain.java:638)
    at com.google.bitcoin.core.AbstractBlockChain.connectBlock(AbstractBlockChain.java:396)
    at com.google.bitcoin.core.AbstractBlockChain.add(AbstractBlockChain.java:349)
    - locked <0x0000000740442c30> (a com.google.bitcoin.core.FullPrunedBlockChain)
    at com.google.bitcoin.core.AbstractBlockChain.add(AbstractBlockChain.java:208)
    - locked <0x0000000740442c30> (a com.google.bitcoin.core.FullPrunedBlockChain)
    at com.google.bitcoin.core.Peer.processBlock(Peer.java:647)
    - locked <0x000000074e16a338> (a com.google.bitcoin.core.Peer)
    at com.google.bitcoin.core.Peer.access$10(Peer.java:633)
    at com.google.bitcoin.core.Peer$PeerHandler.messageReceived(Peer.java:256)
    at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:95)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:777)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndFireMessageReceived(ReplayingDecoder.java:525)
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:501)
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:438)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:553)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
    at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:343)
    at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:274)
    at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:194)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
"New I/O client worker #1-4":
    at com.google.bitcoin.core.Peer.toString(Peer.java:179)
    - waiting to lock <0x000000074e16a338> (a com.google.bitcoin.core.Peer)
    at org.slf4j.helpers.MessageFormatter.safeObjectAppend(MessageFormatter.java:304)
    at org.slf4j.helpers.MessageFormatter.deeplyAppendParameter(MessageFormatter.java:276)
    at org.slf4j.helpers.MessageFormatter.arrayFormat(MessageFormatter.java:230)
    at org.slf4j.helpers.MessageFormatter.format(MessageFormatter.java:124)
    at org.slf4j.impl.Log4jLoggerAdapter.info(Log4jLoggerAdapter.java:322)
    at com.google.bitcoin.core.PeerGroup.setDownloadPeer(PeerGroup.java:859)
    - locked <0x0000000740442940> (a com.google.bitcoin.core.PeerGroup)
    at com.google.bitcoin.core.PeerGroup.handleNewPeer(PeerGroup.java:729)
    - locked <0x0000000740442940> (a com.google.bitcoin.core.PeerGroup)
    at com.google.bitcoin.core.PeerGroup$PeerStartupListener.onPeerConnected(PeerGroup.java:119)
    at com.google.bitcoin.core.Peer$PeerHandler$1.invoke(Peer.java:280)
    at com.google.bitcoin.core.Peer$PeerHandler$1.invoke(Peer.java:1)
    at com.google.bitcoin.utils.EventListenerInvoker.invoke(EventListenerInvoker.java:47)
    - locked <0x00000007404a93e0> (a com.google.bitcoin.core.PeerGroup$PeerStartupListener)
    - locked <0x000000074e74bf50> (a java.util.concurrent.CopyOnWriteArrayList)
    at com.google.bitcoin.core.Peer$PeerHandler.messageReceived(Peer.java:277)
    at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:95)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:777)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.unfoldAndFireMessageReceived(ReplayingDecoder.java:525)
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:501)
    at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:438)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:75)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:553)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
    at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:343)
    at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:274)
    at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:194)
    at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
    at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Found 1 deadlock.

Original issue reported on code.google.com by murexcon...@googlemail.com on 13 Mar 2013 at 11:31

GoogleCodeExporter commented 9 years ago
Sorry - I meant commit  a9bd8631b904 i.e. initial 0.7 release.

Original comment by murexcon...@googlemail.com on 13 Mar 2013 at 11:45

GoogleCodeExporter commented 9 years ago
Please switch to git master. Threading is changing quite significantly right 
now and many of these have already been fixed. Make sure your event listeners 
are thread safe. Don't use the wallet from transaction listeners.

Original comment by hearn@google.com on 14 Mar 2013 at 10:23