Skip to content

android-map-utils: Crash in ClusterTask #660

@claudiofelber

Description

@claudiofelber

The ClusterTask doInBackground() method does sometimes crash. It seems that the write lock is released in a different thread than it is being acquired. The internal ReentrantReadWriteLock.tryRelease() method complains that the lock is not being held exclusively. This might have something to do with the fact that the ClusterTask is now running on the thread pool executor.

Environment details

Tested with android-map-utils 1.0.0 on Android API 28.

Steps to reproduce

Execute the cluster() method repeatedly with lots of items.

Stack trace

2020-03-17 13:56:31.860 29075-29148/ch.infoflora.florapp.dev E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
    Process: ch.infoflora.florapp.dev, PID: 29075
    java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:354)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
        at java.util.concurrent.FutureTask.run(FutureTask.java:271)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.IllegalMonitorStateException
        at java.util.concurrent.locks.ReentrantReadWriteLock$Sync.tryRelease(ReentrantReadWriteLock.java:373)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1285)
        at java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.unlock(ReentrantReadWriteLock.java:1138)
        at com.google.maps.android.clustering.algo.AbstractAlgorithm.unlock(AbstractAlgorithm.java:37)
        at com.google.maps.android.clustering.ClusterManager$ClusterTask.doInBackground(ClusterManager.java:297)
        at com.google.maps.android.clustering.ClusterManager$ClusterTask.doInBackground(ClusterManager.java:290)
        at android.os.AsyncTask$2.call(AsyncTask.java:333)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:764) 

Metadata

Metadata

Assignees

Labels

priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions