mpogue2 / SquareDesk

Fully-featured music player and sequence designer, designed for square dance callers
10 stars 4 forks source link

Bug: New AudioThread code crashes #764

Open mpogue2 opened 1 year ago

mpogue2 commented 1 year ago

@danlyke Tested on MacOS. Seemed very stable on everything I tried, until I let the song end normally, and then it crashed the AudioThread, which crashed the entire app.

This was repeatable, every time I tried, on the songs Caribbean Queen and Appalachian Joy. Interestingly, it did NOT crash on several other songs I tried (patter and singers).

Neither of these songs crash at the end on V1.0.3, so I think it's likely to be caused by the new AudioThread code. I don't see anything special about these 2 songs -- they are both 44.1kHz stereo MP3. Maybe something to do with their lengths?

The (excerpted) crash report below is not very helpful.

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               SquareDesk [36895]
Path:                  /Users/USER/*/SquareDesk.app/Contents/MacOS/SquareDesk
Identifier:            com.zenstarstudio.SquareDesk
Version:               0.9.6 (0.9.6.1)
Code Type:             ARM-64 (Native)
Parent Process:        qtcreator_processlauncher [35879]
User ID:               501

Date/Time:             2023-02-25 16:21:30.6648 -0800
OS Version:            macOS 13.2.1 (22D68)
Report Version:        12
Anonymous UUID:        4921A9E7-C3B3-A1E0-1FFD-EFBC5516BA2E

Sleep/Wake UUID:       B8F74B3B-6397-4343-AE6C-105A29EC20A2

Time Awake Since Boot: 100000 seconds
Time Since Wake:       3465 seconds

System Integrity Protection: enabled

Crashed Thread:        10  QThread

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000001, 0x000000010403c724

Termination Reason:    Namespace SIGNAL, Code 5 Trace/BPT trap: 5
Terminating Process:   exc handler [36895]

Thread 0:: CrBrowserMain Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib                 0x18bf92050 mach_msg2_trap + 8
1   libsystem_kernel.dylib                 0x18bfa411c mach_msg2_internal + 80
2   libsystem_kernel.dylib                 0x18bf9ac24 mach_msg_overwrite + 452
3   libsystem_kernel.dylib                 0x18bf923cc mach_msg + 24
4   CoreFoundation                         0x18c0b1bb0 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                         0x18c0b049c __CFRunLoopRun + 1232
6   CoreFoundation                         0x18c0af878 CFRunLoopRunSpecific + 612
7   HIToolbox                              0x19578ffa0 RunCurrentEventLoopInMode + 292
8   HIToolbox                              0x19578fde4 ReceiveNextEventCommon + 672
9   HIToolbox                              0x19578fb2c _BlockUntilNextEventMatchingListInModeWithFilter + 72
10  AppKit                                 0x18f33584c _DPSNextEvent + 632
11  AppKit                                 0x18f3349dc -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 728
12  AppKit                                 0x18f328e0c -[NSApplication run] + 464
13  libqcocoa.dylib                        0x10882ab18 QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 1800 (qcocoaeventdispatcher.mm:394)
14  QtCore                                 0x105e47fcc QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 36 (qeventloop.cpp:100) [inlined]
15  QtCore                                 0x105e47fcc QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 536 (qeventloop.cpp:182)
16  QtCore                                 0x105e3f618 QCoreApplication::exec() + 128 (qcoreapplication.cpp:1347)
17  SquareDesk                             0x10403a170 main + 1340
18  dyld                                   0x18bca7e50 start + 2544

Thread 1:
0   libsystem_pthread.dylib                0x18bfcce18 start_wqthread + 0

Thread 2:
0   libsystem_pthread.dylib                0x18bfcce18 start_wqthread + 0

Thread 3:: caulk.messenger.shared:17
0   libsystem_kernel.dylib                 0x18bf91fcc semaphore_wait_trap + 8
1   caulk                                  0x1954b6cfc caulk::mach::semaphore::wait_or_error() + 28
2   caulk                                  0x195499634 caulk::concurrent::details::worker_thread::run() + 56
3   caulk                                  0x195499278 void* caulk::thread_proxy<std::__1::tuple<caulk::thread::attributes, void (caulk::concurrent::details::worker_thread::*)(), std::__1::tuple<caulk::concurrent::details::worker_thread*> > >(void*) + 96
4   libsystem_pthread.dylib                0x18bfd206c _pthread_start + 148
5   libsystem_pthread.dylib                0x18bfcce2c thread_start + 8

Thread 4:
0   libsystem_pthread.dylib                0x18bfcce18 start_wqthread + 0

Thread 5:: Thread (pooled)
0   libsystem_kernel.dylib                 0x18bf9584c __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x18bfd2638 _pthread_cond_wait + 1232
2   QtCore                                 0x105fa9634 QWaitConditionPrivate::wait_relative(QDeadlineTimer) + 300 (qwaitcondition_unix.cpp:101)
3   QtCore                                 0x105fa92ec QWaitConditionPrivate::wait(QDeadlineTimer) + 92 (qwaitcondition_unix.cpp:109)
4   QtCore                                 0x105fa922c QWaitCondition::wait(QMutex*, QDeadlineTimer) + 108 (qwaitcondition_unix.cpp:184)
5   QtCore                                 0x105fa3b9c QThreadPoolThread::run() + 860 (qthreadpool.cpp:114)
6   QtCore                                 0x105f9fb08 QThreadPrivate::start(void*)::$_0::operator()() const + 256 (qthread_unix.cpp:321) [inlined]
7   QtCore                                 0x105f9fb08 void (anonymous namespace)::terminate_on_exception<QThreadPrivate::start(void*)::$_0>(QThreadPrivate::start(void*)::$_0&&) + 256 (qthread_unix.cpp:257) [inlined]
8   QtCore                                 0x105f9fb08 QThreadPrivate::start(void*) + 332 (qthread_unix.cpp:280)
9   libsystem_pthread.dylib                0x18bfd206c _pthread_start + 148
10  libsystem_pthread.dylib                0x18bfcce2c thread_start + 8

Thread 6:: Thread (pooled)
0   libsystem_kernel.dylib                 0x18bf9584c __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x18bfd2638 _pthread_cond_wait + 1232
2   QtCore                                 0x105fa9634 QWaitConditionPrivate::wait_relative(QDeadlineTimer) + 300 (qwaitcondition_unix.cpp:101)
3   QtCore                                 0x105fa92ec QWaitConditionPrivate::wait(QDeadlineTimer) + 92 (qwaitcondition_unix.cpp:109)
4   QtCore                                 0x105fa922c QWaitCondition::wait(QMutex*, QDeadlineTimer) + 108 (qwaitcondition_unix.cpp:184)
5   QtCore                                 0x105fa3b9c QThreadPoolThread::run() + 860 (qthreadpool.cpp:114)
6   QtCore                                 0x105f9fb08 QThreadPrivate::start(void*)::$_0::operator()() const + 256 (qthread_unix.cpp:321) [inlined]
7   QtCore                                 0x105f9fb08 void (anonymous namespace)::terminate_on_exception<QThreadPrivate::start(void*)::$_0>(QThreadPrivate::start(void*)::$_0&&) + 256 (qthread_unix.cpp:257) [inlined]
8   QtCore                                 0x105f9fb08 QThreadPrivate::start(void*) + 332 (qthread_unix.cpp:280)
9   libsystem_pthread.dylib                0x18bfd206c _pthread_start + 148
10  libsystem_pthread.dylib                0x18bfcce2c thread_start + 8

Thread 7:: Thread (pooled)
0   libsystem_kernel.dylib                 0x18bf9584c __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x18bfd2638 _pthread_cond_wait + 1232
2   QtCore                                 0x105fa9634 QWaitConditionPrivate::wait_relative(QDeadlineTimer) + 300 (qwaitcondition_unix.cpp:101)
3   QtCore                                 0x105fa92ec QWaitConditionPrivate::wait(QDeadlineTimer) + 92 (qwaitcondition_unix.cpp:109)
4   QtCore                                 0x105fa922c QWaitCondition::wait(QMutex*, QDeadlineTimer) + 108 (qwaitcondition_unix.cpp:184)
5   QtCore                                 0x105fa3b9c QThreadPoolThread::run() + 860 (qthreadpool.cpp:114)
6   QtCore                                 0x105f9fb08 QThreadPrivate::start(void*)::$_0::operator()() const + 256 (qthread_unix.cpp:321) [inlined]
7   QtCore                                 0x105f9fb08 void (anonymous namespace)::terminate_on_exception<QThreadPrivate::start(void*)::$_0>(QThreadPrivate::start(void*)::$_0&&) + 256 (qthread_unix.cpp:257) [inlined]
8   QtCore                                 0x105f9fb08 QThreadPrivate::start(void*) + 332 (qthread_unix.cpp:280)
9   libsystem_pthread.dylib                0x18bfd206c _pthread_start + 148
10  libsystem_pthread.dylib                0x18bfcce2c thread_start + 8

Thread 8:: Thread (pooled)
0   libsystem_kernel.dylib                 0x18bf9584c __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x18bfd2638 _pthread_cond_wait + 1232
2   QtCore                                 0x105fa9634 QWaitConditionPrivate::wait_relative(QDeadlineTimer) + 300 (qwaitcondition_unix.cpp:101)
3   QtCore                                 0x105fa92ec QWaitConditionPrivate::wait(QDeadlineTimer) + 92 (qwaitcondition_unix.cpp:109)
4   QtCore                                 0x105fa922c QWaitCondition::wait(QMutex*, QDeadlineTimer) + 108 (qwaitcondition_unix.cpp:184)
5   QtCore                                 0x105fa3b9c QThreadPoolThread::run() + 860 (qthreadpool.cpp:114)
6   QtCore                                 0x105f9fb08 QThreadPrivate::start(void*)::$_0::operator()() const + 256 (qthread_unix.cpp:321) [inlined]
7   QtCore                                 0x105f9fb08 void (anonymous namespace)::terminate_on_exception<QThreadPrivate::start(void*)::$_0>(QThreadPrivate::start(void*)::$_0&&) + 256 (qthread_unix.cpp:257) [inlined]
8   QtCore                                 0x105f9fb08 QThreadPrivate::start(void*) + 332 (qthread_unix.cpp:280)
9   libsystem_pthread.dylib                0x18bfd206c _pthread_start + 148
10  libsystem_pthread.dylib                0x18bfcce2c thread_start + 8

Thread 9:: com.apple.NSEventThread
0   libsystem_kernel.dylib                 0x18bf92050 mach_msg2_trap + 8
1   libsystem_kernel.dylib                 0x18bfa411c mach_msg2_internal + 80
2   libsystem_kernel.dylib                 0x18bf9ac24 mach_msg_overwrite + 452
3   libsystem_kernel.dylib                 0x18bf923cc mach_msg + 24
4   CoreFoundation                         0x18c0b1bb0 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                         0x18c0b049c __CFRunLoopRun + 1232
6   CoreFoundation                         0x18c0af878 CFRunLoopRunSpecific + 612
7   AppKit                                 0x18f46019c _NSEventThread + 172
8   libsystem_pthread.dylib                0x18bfd206c _pthread_start + 148
9   libsystem_pthread.dylib                0x18bfcce2c thread_start + 8

Thread 10 Crashed:: QThread
0   SquareDesk                             0x10403c724 AudioThread::run() + 872
1   SquareDesk                             0x10403c548 AudioThread::run() + 396
2   QtCore                                 0x105f9fb08 QThreadPrivate::start(void*)::$_0::operator()() const + 256 (qthread_unix.cpp:321) [inlined]
3   QtCore                                 0x105f9fb08 void (anonymous namespace)::terminate_on_exception<QThreadPrivate::start(void*)::$_0>(QThreadPrivate::start(void*)::$_0&&) + 256 (qthread_unix.cpp:257) [inlined]
4   QtCore                                 0x105f9fb08 QThreadPrivate::start(void*) + 332 (qthread_unix.cpp:280)
5   libsystem_pthread.dylib                0x18bfd206c _pthread_start + 148
6   libsystem_pthread.dylib                0x18bfcce2c thread_start + 8
mpogue2 commented 1 year ago

Oh wait! I just noticed an error message on the console, that I would bet is the cause of this crash:

Assertion failed at ../../SquareDesk-DEV/test123/audiothread.cpp:122
m_playPosition_frames < m_totalFramesInSong | 8939458 < 8939456

So, that does suggest that it's the length of the song that matters.

mpogue2 commented 1 year ago

Latest version on @danlyke branch: fcc37585730d1cecf25bf8ac2046d60d65072ab7 works fine now with Caribbean Queen, but still crashes on Appalachian Joy, with this error message:

Assertion failed at ../../SquareDesk-DEV/test123/audiothread.cpp:122
m_playPosition_frames <= m_totalFramesInSong | 9730008 <= 9730004

I emailed you a copy of that one for testing...