arthenica / ffmpeg-kit

FFmpeg Kit for applications. Supports Android, Flutter, iOS, Linux, macOS, React Native and tvOS. Supersedes MobileFFmpeg, flutter_ffmpeg and react-native-ffmpeg.
https://arthenica.github.io/ffmpeg-kit
GNU Lesser General Public License v3.0
4.29k stars 579 forks source link

Crash when running multiple executions in parallel (pthread_mutex_destroy called on a destroyed mutex) #120

Closed SpaceBison closed 2 years ago

SpaceBison commented 3 years ago

Description The library sometimes crashes when running multiple executions at once. The concurrence is handled by RxJava.

Expected behavior The app should not crash.

Current behavior It did.

To Reproduce Unfortunately my current code is too complex to use as a minimal reproducible example. I'll post something as soon as I can.

Logs

A/libc: FORTIFY: pthread_mutex_destroy called on a destroyed mutex (0x6fe90dff98)
A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 18576 (pool-58-thread-), pid 18219 (videocompressor)
A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
A/DEBUG: Build fingerprint: 'Xiaomi/beryllium/beryllium:10/QKQ1.190828.002/V12.0.3.0.QEJMIXM:user/release-keys'
A/DEBUG: Revision: '0'
A/DEBUG: ABI: 'arm64'
A/DEBUG: Timestamp: 2021-08-11 17:31:54+0200
A/DEBUG: pid: 18219, tid: 18576, name: pool-58-thread-  >>> my.app <<<
A/DEBUG: uid: 10558
A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
A/DEBUG: Abort message: 'FORTIFY: pthread_mutex_destroy called on a destroyed mutex (0x6fe90dff98)'
A/DEBUG:     x0  0000000000000000  x1  0000000000004890  x2  0000000000000006  x3  0000006fd99f8520
A/DEBUG:     x4  0080808080808080  x5  0080808080808080  x6  0080808080808080  x7  0000000000000010
A/DEBUG:     x8  00000000000000f0  x9  63c0b6f4fe1a4126  x10 0000000000000001  x11 0000000000000000
A/DEBUG:     x12 fffffff0fffffbdf  x13 000000006113ed65  x14 0017f0a9893794aa  x15 000089e109a9c8c4
A/DEBUG:     x16 0000007069f26738  x17 0000007069f05180  x18 0000006fd89a8000  x19 000000000000472b
A/DEBUG:     x20 0000000000004890  x21 00000000ffffffff  x22 000000000298d350  x23 000000006938a540
A/DEBUG:     x24 0000000000082005  x25 0000000000000000  x26 0000000000082205  x27 0000000000082015
A/DEBUG:     x28 00000000000c4012  x29 0000006fd99f85c0
A/DEBUG:     sp  0000006fd99f8500  lr  0000007069eb686c  pc  0000007069eb6898
A/DEBUG: backtrace:
A/DEBUG:       #00 pc 0000000000073898  /apex/com.android.runtime/lib64/bionic/libc.so (abort+160) (BuildId: f6cc5d2d702265511937b56460b37693)
A/DEBUG:       #01 pc 00000000000d8750  /apex/com.android.runtime/lib64/bionic/libc.so (__fortify_fatal(char const*, ...)+120) (BuildId: f6cc5d2d702265511937b56460b37693)
A/DEBUG:       #02 pc 00000000000d7df0  /apex/com.android.runtime/lib64/bionic/libc.so (HandleUsingDestroyedMutex(pthread_mutex_t*, char const*)+52) (BuildId: f6cc5d2d702265511937b56460b37693)
A/DEBUG:       #03 pc 00000000000d86c4  /apex/com.android.runtime/lib64/bionic/libc.so (pthread_mutex_destroy+140) (BuildId: f6cc5d2d702265511937b56460b37693)
A/DEBUG:       #04 pc 0000000000024f3c  /data/app/my.app-aW4N4QeUs86Etp7BZG9EXQ==/lib/arm64/libffmpegkit.so (exit_program+32) (BuildId: 90bf1d35ecf64feee33f44237f1d7e9cdba975a5)
A/DEBUG:       #05 pc 000000000002e480  /data/app/my.app-aW4N4QeUs86Etp7BZG9EXQ==/lib/arm64/libffmpegkit.so (ffmpeg_execute+10484) (BuildId: 90bf1d35ecf64feee33f44237f1d7e9cdba975a5)
A/DEBUG:       #06 pc 00000000000236b0  /data/app/my.app-aW4N4QeUs86Etp7BZG9EXQ==/lib/arm64/libffmpegkit.so (Java_com_arthenica_ffmpegkit_FFmpegKitConfig_nativeFFmpegExecute+388) (BuildId: 90bf1d35ecf64feee33f44237f1d7e9cdba975a5)
A/DEBUG:       #07 pc 0000000000140350  /apex/com.android.runtime/lib64/libart.so (art_quick_generic_jni_trampoline+144) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #08 pc 00000000001375b8  /apex/com.android.runtime/lib64/libart.so (art_quick_invoke_static_stub+568) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #09 pc 000000000014600c  /apex/com.android.runtime/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+276) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #10 pc 00000000002e37d0  /apex/com.android.runtime/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+384) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #11 pc 00000000002dea30  /apex/com.android.runtime/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+892) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #12 pc 00000000005a3a78  /apex/com.android.runtime/lib64/libart.so (MterpInvokeStatic+372) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #13 pc 0000000000131994  /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #14 pc 00000000004b22cc  [anon:dalvik-classes.dex extracted in memory from /data/app/my.app-aW4N4QeUs86Etp7BZG9EXQ==/base.apk] (com.arthenica.ffmpegkit.FFmpegKitConfig.ffmpegExecute+28)
A/DEBUG:       #15 pc 00000000005a3d14  /apex/com.android.runtime/lib64/libart.so (MterpInvokeStatic+1040) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #16 pc 0000000000131994  /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_static+20) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #17 pc 00000000004b1194  [anon:dalvik-classes.dex extracted in memory from /data/app/my.app-aW4N4QeUs86Etp7BZG9EXQ==/base.apk] (com.arthenica.ffmpegkit.AsyncFFmpegExecuteTask.run+4)
A/DEBUG:       #18 pc 00000000002b4ae4  /apex/com.android.runtime/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.17460956533834400288+240) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #19 pc 000000000059250c  /apex/com.android.runtime/lib64/libart.so (artQuickToInterpreterBridge+1032) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #20 pc 0000000000140468  /apex/com.android.runtime/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #21 pc 00000000020b5bb4  /memfd:/jit-cache (deleted) (java.util.concurrent.Executors$RunnableAdapter.call+68)
A/DEBUG:       #22 pc 00000000020c2ec8  /memfd:/jit-cache (deleted) (java.util.concurrent.FutureTask.run+200)
A/DEBUG:       #23 pc 0000000000137334  /apex/com.android.runtime/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #24 pc 0000000000145fec  /apex/com.android.runtime/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+244) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #25 pc 00000000002e37d0  /apex/com.android.runtime/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+384) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #26 pc 00000000002dea30  /apex/com.android.runtime/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+892) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #27 pc 00000000005a275c  /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+980) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #28 pc 0000000000131a14  /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_interface+20) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #29 pc 00000000001f8182  /apex/com.android.runtime/javalib/core-oj.jar (java.util.concurrent.ThreadPoolExecutor.runWorker+158)
A/DEBUG:       #30 pc 00000000005a1264  /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtual+1352) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #31 pc 0000000000131814  /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_virtual+20) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #32 pc 00000000001f6f30  /apex/com.android.runtime/javalib/core-oj.jar (java.util.concurrent.ThreadPoolExecutor$Worker.run+4)
A/DEBUG:       #33 pc 00000000005a2a84  /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1788) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #34 pc 0000000000131a14  /apex/com.android.runtime/lib64/libart.so (mterp_op_invoke_interface+20) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #35 pc 00000000000ea988  /apex/com.android.runtime/javalib/core-oj.jar (java.lang.Thread.run+8)
A/DEBUG:       #36 pc 00000000002b4ae4  /apex/com.android.runtime/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.17460956533834400288+240) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #37 pc 000000000059250c  /apex/com.android.runtime/lib64/libart.so (artQuickToInterpreterBridge+1032) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #38 pc 0000000000140468  /apex/com.android.runtime/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #39 pc 0000000000137334  /apex/com.android.runtime/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #40 pc 0000000000145fec  /apex/com.android.runtime/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+244) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #41 pc 00000000004b0f10  /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+104) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #42 pc 00000000004b2024  /apex/com.android.runtime/lib64/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue const*)+416) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #43 pc 00000000004f29e0  /apex/com.android.runtime/lib64/libart.so (art::Thread::CreateCallback(void*)+1176) (BuildId: 03574df7f7eb01baf6baa6348024974c)
A/DEBUG:       #44 pc 00000000000d7110  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36) (BuildId: f6cc5d2d702265511937b56460b37693)
A/DEBUG:       #45 pc 0000000000075314  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: f6cc5d2d702265511937b56460b37693)

Environment

tanersener commented 3 years ago

It seems like it is the duplicate of #72.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.