Description
System and IINA version:
- macOS 13.6.3
- IINA
develop
with some changes that were being tested
Expected behavior:
IINA does not crash.
Actual behavior:
IINA crashed while quitting when a background thread was still finding and adding files to the playlist.
As can be seen in the portion of the crash report below, the mpv client was being destroyed at the same time the background thread was running AutoFileMatcher.addFilesToPlaylist
.
Crash report:
Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x195ec6bbc madvise + 8
1 libsystem_malloc.dylib 0x195d2f064 mvm_madvise_free + 108
2 libsystem_malloc.dylib 0x195d2d720 free_medium + 2444
3 libmpv.2.dylib 0x1059a9aa0 ta_free_children + 88
4 libmpv.2.dylib 0x1059a990c ta_free + 104
5 libmpv.2.dylib 0x10594bc54 mp_destroy + 240
6 libmpv.2.dylib 0x10592ed80 mp_destroy_client + 940
7 IINA 0x1012cb7dc MPVController.mpvUninitRendering() + 232 (MPVController.swift:692)
8 IINA 0x1011843a4 closure #1 in VideoView.uninit() + 480 (VideoView.swift:96)
9 IINA 0x1011843e0 partial apply for closure #1 in VideoView.uninit() + 24
10 IINA 0x100fe06ac closure #1 in Atomic.withLock<A>(_:) + 136 (Atomic.swift:32)
11 IINA 0x100fe0730 partial apply for closure #1 in Atomic.withLock<A>(_:) + 44
12 IINA 0x10117873c OSUnfairLockImpl.withLock<A>(_:) + 104 (Lock.swift:70)
13 IINA 0x101178894 protocol witness for LockImpl.withLock<A>(_:) in conformance OSUnfairLockImpl + 32
14 IINA 0x1011784a4 Lock.withLock<A>(_:) + 144 (Lock.swift:42)
15 IINA 0x100fe05bc Atomic.withLock<A>(_:) + 168 (Atomic.swift:31)
16 IINA 0x10118418c VideoView.uninit() + 132 (VideoView.swift:91)
17 IINA 0x10123447c PlayerCore.uninitVideo() + 484 (PlayerCore.swift:519)
18 IINA 0x10123491c PlayerCore.mpvHasShutdown(isMPVInitiated:) + 604 (PlayerCore.swift:552)
19 IINA 0x1012d7e64 closure #1 in MPVController.handleEvent(_:) + 104 (MPVController.swift:1051)
20 IINA 0x100ddd814 thunk for @escaping @callee_guaranteed () -> () + 48
21 libdispatch.dylib 0x195d52874 _dispatch_call_block_and_release + 32
22 libdispatch.dylib 0x195d54400 _dispatch_client_callout + 20
23 libdispatch.dylib 0x195d62bf8 _dispatch_main_queue_drain + 928
24 libdispatch.dylib 0x195d62848 _dispatch_main_queue_callback_4CF + 44
25 CoreFoundation 0x196023bc4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
26 CoreFoundation 0x195fe1344 __CFRunLoopRun + 1992
27 CoreFoundation 0x195fe0428 CFRunLoopRunSpecific + 612
28 HIToolbox 0x19f834df0 RunCurrentEventLoopInMode + 292
29 HIToolbox 0x19f834c2c ReceiveNextEventCommon + 648
30 HIToolbox 0x19f834984 _BlockUntilNextEventMatchingListInModeWithFilter + 76
31 AppKit 0x199208908 _DPSNextEvent + 636
32 AppKit 0x199207aa4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
33 AppKit 0x19942917c -[NSApplication _shouldTerminate] + 700
34 AppKit 0x19953f894 -[NSApplication(NSAppleEventHandling) _handleAEQuit] + 268
35 AppKit 0x19920d818 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 672
36 Foundation 0x196f30b14 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 316
37 Foundation 0x196f30974 _NSAppleEventManagerGenericHandler + 80
38 AE 0x19c30f55c 0x19c303000 + 50524
39 AE 0x19c30ee88 0x19c303000 + 48776
40 AE 0x19c307f5c aeProcessAppleEvent + 488
41 HIToolbox 0x19f844cf4 AEProcessAppleEvent + 68
42 AppKit 0x199208c0c _DPSNextEvent + 1408
43 AppKit 0x199207aa4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
44 AppKit 0x1991fbf08 -[NSApplication run] + 464
45 AppKit 0x1991d3358 NSApplicationMain + 880
46 IINA 0x100ffa0ac main + 12 (AppDelegate.swift:24)
47 dyld 0x195babf28 start + 2236
…
Thread 2 Crashed:: Dispatch queue: IINAPlayerCoreTask
0 libmpv.2.dylib 0x105930754 mpv_get_property + 16
1 IINA 0x1012d0c28 MPVController.getInt(_:) + 572 (MPVController.swift:833)
2 IINA 0x100ec850c AutoFileMatcher.addFilesToPlaylist() + 2956 (AutoFileMatcher.swift:129)
3 IINA 0x100ecfaa4 AutoFileMatcher.startMatching() + 2020 (AutoFileMatcher.swift:348)
4 IINA 0x101256664 PlayerCore.autoLoadFilesInCurrentFolder(ticket:) + 92 (PlayerCore.swift:2018)
5 IINA 0x10124fc18 closure #3 in PlayerCore.fileStarted(path:) + 416 (PlayerCore.swift:1739)
6 IINA 0x100f45c18 thunk for @escaping @callee_guaranteed @Sendable () -> () + 48
7 libdispatch.dylib 0x195d52874 _dispatch_call_block_and_release + 32
8 libdispatch.dylib 0x195d54400 _dispatch_client_callout + 20
9 libdispatch.dylib 0x195d5ba88 _dispatch_lane_serial_drain + 668
10 libdispatch.dylib 0x195d5c5f8 _dispatch_lane_invoke + 384
11 libdispatch.dylib 0x195d67244 _dispatch_workloop_worker_thread + 648
12 libsystem_pthread.dylib 0x195f00074 _pthread_wqthread + 288
13 libsystem_pthread.dylib 0x195efed94 start_wqthread + 8
Steps to reproduce:
This was reproduced by running a script that starts and quits IINA over and over again to test for proper shutdown coordination.
- MPV does not have this problem.
How often does this happen?
Rarely during my testing. Likely a test can be made that would make this more likely to occur.