You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The HashSet-based loadedLibraries field inReLinkerInstance holding the names of already loaded library names is not thread-safe or guarded with a mutex. Relinker.loadLibrary() can be called from multiple threads either by user code or by loading asynchronously via a LoadListener, so it is a good idea to either use a lock on the Set, or Collections.synchonizedSet() or better, just pick something appropiate from java.util.concurrent like a ConcurrentHashMap wrapped with Collections.newSetFromMap()
The text was updated successfully, but these errors were encountered:
Thanks for bringing this up.
Do you ever run into the issue where you load it from multiple threads? For us, we load libraries on app start from one place.
It would be great if you'd open a PR for this. I think there is no downside in making it thread safe.
I will do a fork and open a PR.
There one more thing in my mind for which I am not sure to open an issue or just merge it with the current change request. Currently I am using the library though a singleton-like wrapper which does not need an Context argument, but uses a non-exported ContentProvider which gets a reference to the application context on launch of the app. This way I very much have a drop-in replacement for System.loadLibray().
Do you interest in such a change, I can open a PR for it as well?
The
HashSet
-basedloadedLibraries
field inReLinkerInstance
holding the names of already loaded library names is not thread-safe or guarded with a mutex.Relinker.loadLibrary()
can be called from multiple threads either by user code or by loading asynchronously via aLoadListener
, so it is a good idea to either use a lock on theSet
, orCollections.synchonizedSet()
or better, just pick something appropiate fromjava.util.concurrent
like aConcurrentHashMap
wrapped withCollections.newSetFromMap()
The text was updated successfully, but these errors were encountered: