Deadlock in vlc-android
Type
"main" prio=5 tid=1 Native
#00 pc 000000000004b9dc /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28)
#00 pc 000000000004f5d4 /apex/com.android.runtime/lib64/bionic/libc.so (__futex_wait_ex(void volatile*, bool, int, bool, timespec const*)+144)
#00 pc 00000000000b52ec /apex/com.android.runtime/lib64/bionic/libc.so (NonPI::MutexLockWithTimeout(pthread_mutex_internal_t*, bool, timespec const*)+216)
#00 pc 00000000000935cc /data/app/~~pF264OaIfbkSc7eTvv_KPQ==/org.videolan.vlc-Q-xKgJhG38kUHw8P5f4R-w==/lib/arm64/libc++_shared.so (std::__ndk1::mutex::lock()+8)
#00 pc 000000000012bf50 /data/app/~~pF264OaIfbkSc7eTvv_KPQ==/org.videolan.vlc-Q-xKgJhG38kUHw8P5f4R-w==/lib/arm64/libmla.so (medialibrary::MediaLibrary::resumeBackgroundOperations()+28)
#00 pc 00000000000f9b54 /data/app/~~pF264OaIfbkSc7eTvv_KPQ==/org.videolan.vlc-Q-xKgJhG38kUHw8P5f4R-w==/lib/arm64/libmla.so (AndroidMediaLibrary::resumeBackgroundOperations()+28)
at org.videolan.medialibrary.MedialibraryImpl.nativeResumeBackgroundOperations (Native method)
at org.videolan.medialibrary.MedialibraryImpl.resumeBackgroundOperations (MedialibraryImpl.java:392)
at org.videolan.vlc.gui.video.VideoPlayerActivity.onStop (VideoPlayerActivity.kt:715)
at android.app.Instrumentation.callActivityOnStop (Instrumentation.java:1476)
at android.app.Activity.performStop (Activity.java:8209)
at android.app.ActivityThread.callActivityOnStop (ActivityThread.java:4850)
at android.app.ActivityThread.performStopActivityInner (ActivityThread.java:4829)
at android.app.ActivityThread.handleStopActivity (ActivityThread.java:4903)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence (TransactionExecutor.java:233)
at android.app.servertransaction.TransactionExecutor.cycleToPath (TransactionExecutor.java:201)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:173)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2067)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:223)
at android.app.ActivityThread.main (ActivityThread.java:7670)
at java.lang.reflect.Method.invoke (Native method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:594)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:943)
Type
"DefaultDispatcher-worker-4 @coroutine#21" daemon prio=5 tid=27 Native
#00 pc 000000000004b9dc /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28)
#00 pc 000000000004f5d4 /apex/com.android.runtime/lib64/bionic/libc.so (__futex_wait_ex(void volatile*, bool, int, bool, timespec const*)+144)
#00 pc 00000000000b52ec /apex/com.android.runtime/lib64/bionic/libc.so (NonPI::MutexLockWithTimeout(pthread_mutex_internal_t*, bool, timespec const*)+216)
#00 pc 00000000000935cc /data/app/~~pF264OaIfbkSc7eTvv_KPQ==/org.videolan.vlc-Q-xKgJhG38kUHw8P5f4R-w==/lib/arm64/libc++_shared.so (std::__ndk1::mutex::lock()+8)
#00 pc 0000000000195694 /data/app/~~pF264OaIfbkSc7eTvv_KPQ==/org.videolan.vlc-Q-xKgJhG38kUHw8P5f4R-w==/lib/arm64/libmla.so (medialibrary::FsHolder::registerCallback(medialibrary::IFsHolderCb*)+44)
#00 pc 000000000010c840 /data/app/~~pF264OaIfbkSc7eTvv_KPQ==/org.videolan.vlc-Q-xKgJhG38kUHw8P5f4R-w==/lib/arm64/libmla.so (medialibrary::MediaLibrary::startParser()+496)
#00 pc 000000000012b200 /data/app/~~pF264OaIfbkSc7eTvv_KPQ==/org.videolan.vlc-Q-xKgJhG38kUHw8P5f4R-w==/lib/arm64/libmla.so (medialibrary::MediaLibrary::reload()+68)
at org.videolan.medialibrary.MedialibraryImpl.nativeReload (Native method)
at org.videolan.medialibrary.MedialibraryImpl.reload (MedialibraryImpl.java:396)
at org.videolan.vlc.MediaParsingService.reload (MediaParsingService.kt:244)
at org.videolan.vlc.MediaParsingService.startScan (MediaParsingService.kt:303)
at org.videolan.vlc.MediaParsingService.initMedialib (MediaParsingService.kt:259)
at org.videolan.vlc.MediaParsingService.processAction (MediaParsingService.kt:471)
at org.videolan.vlc.MediaParsingService$processAction$1.invokeSuspend (MediaParsingService.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith (ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run (DispatchedTask.kt:106)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely (CoroutineScheduler.kt:571)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask (CoroutineScheduler.kt:738)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker (CoroutineScheduler.kt:678)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run (CoroutineScheduler.kt:665)
Type
"AndroidMedialibrary" prio=5 tid=35 Native
#00 pc 000000000004b9dc /apex/com.android.runtime/lib64/bionic/libc.so (syscall+28)
#00 pc 000000000004f5d4 /apex/com.android.runtime/lib64/bionic/libc.so (__futex_wait_ex(void volatile*, bool, int, bool, timespec const*)+144)
#00 pc 00000000000b52ec /apex/com.android.runtime/lib64/bionic/libc.so (NonPI::MutexLockWithTimeout(pthread_mutex_internal_t*, bool, timespec const*)+216)
#00 pc 00000000000935cc /data/app/~~pF264OaIfbkSc7eTvv_KPQ==/org.videolan.vlc-Q-xKgJhG38kUHw8P5f4R-w==/lib/arm64/libc++_shared.so (std::__ndk1::mutex::lock()+8)
#00 pc 0000000000195a8c /data/app/~~pF264OaIfbkSc7eTvv_KPQ==/org.videolan.vlc-Q-xKgJhG38kUHw8P5f4R-w==/lib/arm64/libmla.so (medialibrary::FsHolder::onDeviceMounted(medialibrary::fs::IDevice const&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)+528)
#00 pc 0000000000208910 /data/app/~~pF264OaIfbkSc7eTvv_KPQ==/org.videolan.vlc-Q-xKgJhG38kUHw8P5f4R-w==/lib/arm64/libmla.so (medialibrary::fs::libvlc::FileSystemFactory::onDeviceMounted(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, bool)+740)
#00 pc 00000000000fe878 /data/app/~~pF264OaIfbkSc7eTvv_KPQ==/org.videolan.vlc-Q-xKgJhG38kUHw8P5f4R-w==/lib/arm64/libmla.so (AndroidDeviceLister::refresh()+192)
#00 pc 0000000000195174 /data/app/~~pF264OaIfbkSc7eTvv_KPQ==/org.videolan.vlc-Q-xKgJhG38kUHw8P5f4R-w==/lib/arm64/libmla.so (medialibrary::FsHolder::startFsFactoriesAndRefresh()+136)
#00 pc 0000000000181530 /data/app/~~pF264OaIfbkSc7eTvv_KPQ==/org.videolan.vlc-Q-xKgJhG38kUHw8P5f4R-w==/lib/arm64/libmla.so (medialibrary::DiscovererWorker::run()+208)
#00 pc 0000000000185098 /data/app/~~pF264OaIfbkSc7eTvv_KPQ==/org.videolan.vlc-Q-xKgJhG38kUHw8P5f4R-w==/lib/arm64/libmla.so (void* std::__ndk1::__thread_proxy<std::__ndk1::tuple<std::__ndk1::unique_ptr<std::__ndk1::__thread_struct, std::__ndk1::default_delete<std::__ndk1::__thread_struct> >, void (medialibrary::DiscovererWorker::*)(), medialibrary::DiscovererWorker*> >(void*)+64)
#00 pc 00000000000b4510 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64)
#00 pc 0000000000050808 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)
It seems the thread 35 is enough for this deadlock as it locks the FS holder mutex when invoking FsHolder::startFsFactoriesAndRefresh()
, and tries again to lock it in the same thread when called back by the device lister
If I'm reading this correctly then having a removable device plugged in when the discoverer starts is enough to reproduce this