saalfeldlab / paintera

GNU General Public License v2.0
100 stars 17 forks source link

Race condition when quickly toggling neurons with synapses #344

Closed igorpisarev closed 4 years ago

igorpisarev commented 5 years ago

This exception was thrown on several threads at the same time, it seems that the contains() method in FragmentsInSelectedSegments needs some sort of synchronization:

java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: 45
    at net.imglib2.cache.ref.SoftRefLoaderCache.get(SoftRefLoaderCache.java:112)
    at net.imglib2.cache.util.LoaderCacheAsCacheAdapter.get(LoaderCacheAsCacheAdapter.java:43)
    at net.imglib2.cache.ref.WeakRefVolatileCache.getBlocking(WeakRefVolatileCache.java:451)
    at net.imglib2.cache.ref.WeakRefVolatileCache.access$000(WeakRefVolatileCache.java:20)
    at net.imglib2.cache.ref.WeakRefVolatileCache$FetchEntry.call(WeakRefVolatileCache.java:498)
    at net.imglib2.cache.ref.WeakRefVolatileCache$FetchEntry.call(WeakRefVolatileCache.java:475)
    at net.imglib2.cache.queue.FetcherThreads$Fetcher.run(FetcherThreads.java:177)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 45
    at gnu.trove.impl.hash.TLongHash.indexRehashed(TLongHash.java:233)
    at gnu.trove.impl.hash.TLongHash.index(TLongHash.java:219)
    at gnu.trove.impl.hash.TLongHash.contains(TLongHash.java:163)
    at org.janelia.saalfeldlab.paintera.control.selection.FragmentsInSelectedSegments.contains(FragmentsInSelectedSegments.java:47)
    at org.janelia.saalfeldlab.paintera.state.IntersectingSourceState.lambda$checkForLabelMultisetType$10(IntersectingSourceState.java:288)
    at org.janelia.saalfeldlab.paintera.state.LabelIntersectionCellLoader.load(LabelIntersectionCellLoader.java:73)
    at net.imglib2.cache.img.LoadedCellCacheLoader.get(LoadedCellCacheLoader.java:91)
    at net.imglib2.cache.img.LoadedCellCacheLoader.get(LoadedCellCacheLoader.java:51)
    at net.imglib2.cache.ref.SoftRefLoaderCache.get(SoftRefLoaderCache.java:102)
    ... 6 more
igorpisarev commented 4 years ago

This should be fixed now by merging #377