Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConcurrentModificationException on receiving NewAccountingBlockBroadcastMessage #6545

Closed
Moty28 opened this issue Jan 29, 2023 · 3 comments · Fixed by #6551
Closed

ConcurrentModificationException on receiving NewAccountingBlockBroadcastMessage #6545

Moty28 opened this issue Jan 29, 2023 · 3 comments · Fixed by #6551

Comments

@Moty28
Copy link

Moty28 commented Jan 29, 2023

Description

Version

Steps to reproduce

Expected b

bisq_log.txt
ehaviour

Actual behaviour

Screenshots

Device or machine

Additional info

bisq_log.txt

@boring-cyborg
Copy link

boring-cyborg bot commented Jan 29, 2023

Thanks for opening your first issue here!

Be sure to follow the issue template. Your issue will be reviewed by a maintainer and labeled for further action.

@ghost
Copy link

ghost commented Jan 30, 2023

@alvasw @HenrikJannsen

ConcurrentModificationException receiving a NewAccountingBlockBroadcastMessage on the main thread while processing a list of accountingBlock on a worker thread?

See attached file bisq_log.txt in OP.

Summary:

de gen.-29 21:31:35.096 [ForkJoinPool.commonPool-worker-3] INFO  b.c.d.b.a.BurningManAccountingService: Add new accountingBlock at height 774092 at Sat Jan 28 23:35:39 CET 2023 with 4 txs 
de gen.-29 21:31:35.117 [ForkJoinPool.commonPool-worker-3] INFO  b.c.d.b.a.BurningManAccountingService: Add new accountingBlock at height 774093 at Sat Jan 28 23:44:45 CET 2023 with 3 txs 
de gen.-29 21:31:35.131 [ForkJoinPool.commonPool-worker-3] INFO  b.c.d.b.a.BurningManAccountingService: Add new accountingBlock at height 774094 at Sat Jan 28 23:47:56 CET 2023 with 1 txs 
de gen.-29 21:31:35.144 [ForkJoinPool.commonPool-worker-3] INFO  b.c.d.b.a.BurningManAccountingService: Add new accountingBlock at height 774095 at Sun Jan 29 00:09:25 CET 2023 with 3 txs 
de gen.-29 21:31:35.158 [ForkJoinPool.commonPool-worker-3] INFO  b.c.d.b.a.BurningManAccountingService: Add new accountingBlock at height 774096 at Sun Jan 29 00:11:18 CET 2023 with 1 txs 
de gen.-29 21:31:35.166 [JavaFX Application Thread] INFO  b.c.d.b.a.n.l.n.AccountingLiteNodeNetworkService: We received a NewAccountingBlockBroadcastMessage from peer 67wlqjfw4oxpsm237nvtcy6p6cw2qzq3sy3rpwkph6roltjyvt6nejad.onion:9999 and broadcast it to our peers. height=774230 truncatedHash=ByteArray{bytes as Hex=89f12e2b} 
de gen.-29 21:31:35.168 [JavaFX Application Thread] INFO  b.c.d.b.a.n.l.AccountingLiteNode: onNewBlockReceived: accountingBlock at height 774230 
de gen.-29 21:31:35.176 [ForkJoinPool.commonPool-worker-3] INFO  b.c.d.b.a.BurningManAccountingService: Add new accountingBlock at height 774097 at Sun Jan 29 00:23:50 CET 2023 with 1 txs 
de gen.-29 21:31:35.185 [JavaFX Application Thread] ERROR b.c.s.CommonSetup: Uncaught Exception from thread JavaFX Application Thread 
de gen.-29 21:31:35.185 [JavaFX Application Thread] ERROR b.c.s.CommonSetup: throwableMessage= null 
de gen.-29 21:31:35.185 [JavaFX Application Thread] ERROR b.c.s.CommonSetup: throwableClass= class java.util.ConcurrentModificationException 
de gen.-29 21:31:35.189 [JavaFX Application Thread] ERROR b.c.s.CommonSetup: Stack trace:
java.util.ConcurrentModificationException
    at java.base/java.util.LinkedList$LLSpliterator.forEachRemaining(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
    at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.base/java.util.stream.ReferencePipeline.reduce(Unknown Source)
    at java.base/java.util.stream.ReferencePipeline.max(Unknown Source)
    at bisq.core.dao.burningman.accounting.BurningManAccountingService.getLastBlock(BurningManAccountingService.java:163)
    at bisq.core.dao.burningman.accounting.BurningManAccountingService.addBlock(BurningManAccountingService.java:138)
    at bisq.core.dao.burningman.accounting.node.lite.AccountingLiteNode.processNewAccountingBlock(AccountingLiteNode.java:242)
    at bisq.core.dao.burningman.accounting.node.lite.AccountingLiteNode.onNewBlockReceived(AccountingLiteNode.java:133)
    at bisq.core.dao.burningman.accounting.node.lite.network.AccountingLiteNodeNetworkService.lambda$onMessage$3(AccountingLiteNodeNetworkService.java:232)
    at java.base/java.util.concurrent.CopyOnWriteArrayList.forEach(Unknown Source)
    at bisq.core.dao.burningman.accounting.node.lite.network.AccountingLiteNodeNetworkService.onMessage(AccountingLiteNodeNetworkService.java:232)
    at bisq.network.p2p.network.NetworkNode.lambda$onMessage$7(NetworkNode.java:434)
    at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source)
    at java.base/java.util.stream.ReferencePipeline$Head.forEach(Unknown Source)
    at bisq.network.p2p.network.NetworkNode.onMessage(NetworkNode.java:434)
    at bisq.network.p2p.network.Connection.lambda$onBundleOfEnvelopes$8(Connection.java:425)
    at java.base/java.util.concurrent.CopyOnWriteArrayList.forEach(Unknown Source)
    at java.base/java.util.concurrent.CopyOnWriteArraySet.forEach(Unknown Source)
    at bisq.network.p2p.network.Connection.lambda$onBundleOfEnvelopes$9(Connection.java:425)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:447)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:446)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Unknown Source)
 
de gen.-29 21:31:35.193 [ForkJoinPool.commonPool-worker-3] INFO  b.c.d.b.a.BurningManAccountingService: Add new accountingBlock at height 774098 at Sun Jan 29 00:28:16 CET 2023 with 0 txs 
de gen.-29 21:31:35.210 [ForkJoinPool.commonPool-worker-3] INFO  b.c.d.b.a.BurningManAccountingService: Add new accountingBlock at height 774099 at Sun Jan 29 01:07:49 CET 2023 with 0 txs 
de gen.-29 21:31:35.232 [ForkJoinPool.commonPool-worker-3] INFO  b.c.d.b.a.BurningManAccountingService: Add new accountingBlock at height 774100 at Sun Jan 29 01:09:02 CET 2023 with 0 txs 
de gen.-29 21:31:35.253 [ForkJoinPool.commonPool-worker-3] INFO  b.c.d.b.a.BurningManAccountingService: Add new accountingBlock at height 774101 at Sun Jan 29 01:23:47 CET 2023 with 0 txs 

@alvasw
Copy link
Contributor

alvasw commented Feb 1, 2023

Good news, I found the bug.

alvasw added a commit to alvasw/bisq that referenced this issue Feb 1, 2023
Multiple threads read and write to the accounting blocks list causing
data races. Luckily, the LinkedList threw a ConcurrentModificationException
to limit damage. Now, a ReadWriteLock protects the LinkedList against
data races. Multiple threads can read the list at the same time but only
one thread can write to it. Other writing threads wait until it's their
turn.

Fixes bisq-network#6545
alvasw added a commit to alvasw/bisq that referenced this issue Feb 2, 2023
Multiple threads read and write to the accounting blocks list causing
data races. Luckily, the LinkedList threw a ConcurrentModificationException
to limit damage. Now, a ReadWriteLock protects the LinkedList against
data races. Multiple threads can read the list at the same time but only
one thread can write to it. Other writing threads wait until it's their
turn.

Fixes bisq-network#6545
alvasw added a commit to alvasw/bisq that referenced this issue Feb 3, 2023
Multiple threads read and write to the accounting blocks list causing
data races. Luckily, the LinkedList threw a ConcurrentModificationException
to limit damage. Now, a ReadWriteLock protects the LinkedList against
data races. Multiple threads can read the list at the same time but only
one thread can write to it. Other writing threads wait until it's their
turn.

Fixes bisq-network#6545
alvasw added a commit to alvasw/bisq that referenced this issue Feb 3, 2023
Multiple threads read and write to the accounting blocks list causing
data races. Luckily, the LinkedList threw a ConcurrentModificationException
to limit damage. Now, a ReadWriteLock protects the LinkedList against
data races. Multiple threads can read the list at the same time but only
one thread can write to it. Other writing threads wait until it's their
turn.

Fixes bisq-network#6545
alvasw added a commit to alvasw/bisq that referenced this issue Feb 3, 2023
Multiple threads read and write to the accounting blocks list causing
data races. Luckily, the LinkedList threw a ConcurrentModificationException
to limit damage. Now, a ReadWriteLock protects the LinkedList against
data races. Multiple threads can read the list at the same time but only
one thread can write to it. Other writing threads wait until it's their
turn.

Fixes bisq-network#6545
@alejandrogarcia83 alejandrogarcia83 changed the title Unexpected java error ConcurrentModificationException on receiving NewAccountingBlockBroadcastMessage Feb 4, 2023
This was referenced Mar 7, 2023
@ghost ghost mentioned this issue Mar 23, 2023
@ghost ghost mentioned this issue May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants