UltraStar-Deluxe / USDX

The free and open source karaoke singing game UltraStar Deluxe, inspired by Sony SingStar™
https://usdx.eu
GNU General Public License v2.0
879 stars 162 forks source link

EXC_BAD_INSTRUCTION in libswresample during song playback on macOS #699

Closed umxprime closed 1 year ago

umxprime commented 1 year ago

Actual behaviour

Given I start playing a song the app quits unexpectedly.

Expected behaviour

Song playback shouldn't crash app .

Steps to reproduce

  1. Open UltraStarDeluxe.app
  2. Start a game
  3. Choose player
  4. Choose and start a song
  5. Play

Details

Provide some additional information:

Here's the responsible thread's backtrace

* thread #10, name = 'AudioQueue thread', stop reason = EXC_BAD_INSTRUCTION (code=1, subcode=0x4f21fe14)
  * frame #0: 0x0000000100ab11b4 libswresample.4.dylib`___lldb_unnamed_symbol78 + 60
    frame #1: 0x0000000100ab1d44 libswresample.4.dylib`___lldb_unnamed_symbol93 + 528
    frame #2: 0x0000000100ab7db8 libswresample.4.dylib`___lldb_unnamed_symbol224 + 80
    frame #3: 0x0000000100ab7b30 libswresample.4.dylib`swr_convert + 524
    frame #4: 0x00000001000ffc1c ultrastardx`UAUDIODECODER_FFMPEG$_$TFFMPEGDECODESTREAM_$__$$_READDATA$PBYTEARRAY$LONGINT$$LONGINT + 284
    frame #5: 0x00000001000f63c4 ultrastardx`UAUDIOPLAYBACK_SOFTMIXER$_$TGENERICPLAYBACKSTREAM_$__$$_READDATA$PBYTEARRAY$LONGINT$$LONGINT + 708
    frame #6: 0x00000001000f57cc ultrastardx`UAUDIOPLAYBACK_SOFTMIXER$_$TAUDIOMIXERSTREAM_$__$$_READDATA$PBYTEARRAY$LONGINT$$LONGINT + 220
    frame #7: 0x00000001000fc080 ultrastardx`UAUDIOPLAYBACK_SDL_$$_SDLAUDIOCALLBACK$POINTER$PBYTEARRAY$LONGINT + 16
    frame #8: 0x0000000100c7ac1c libSDL2-2.0.0.dylib`outputCallback + 384
    frame #9: 0x000000019d5c71d8 AudioToolbox`ClientAudioQueue::CallOutputCallback(AudioQueueBuffer*) + 292
    frame #10: 0x000000019d5b1378 AudioToolbox`ClientAudioQueue::FetchAndDeliverPendingCallbacks(unsigned int) + 812
    frame #11: 0x000000019d5b0fbc AudioToolbox`_XCallbackNotificationsAvailable + 216
    frame #12: 0x000000019c48b18c libAudioToolboxUtility.dylib`mshMIGPerform + 264
    frame #13: 0x000000018fefd818 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 60
    frame #14: 0x000000018fefd6d4 CoreFoundation`__CFRunLoopDoSource1 + 604
    frame #15: 0x000000018fefbb68 CoreFoundation`__CFRunLoopRun + 2372
    frame #16: 0x000000018fefaa84 CoreFoundation`CFRunLoopRunSpecific + 600
    frame #17: 0x0000000100c7a7c4 libSDL2-2.0.0.dylib`audioqueue_thread + 1152
    frame #18: 0x0000000100c11dcc libSDL2-2.0.0.dylib`SDL_RunThread + 48
    frame #19: 0x0000000100c67370 libSDL2-2.0.0.dylib`RunThread + 12
    frame #20: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148

And here is the full backtrace

(lldb) th ba all
  thread #1, queue = 'com.apple.main-thread'
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000100c67c80 libSDL2-2.0.0.dylib`SDL_CondWait_REAL + 20
    frame #3: 0x0000000100c5b6d4 libSDL2-2.0.0.dylib`Cocoa_GL_SwapWindow + 136
    frame #4: 0x00000001000763a8 ultrastardx`UGRAPHIC_$$_SWAPBUFFERS + 24
    frame #5: 0x000000010007bec0 ultrastardx`UMAIN_$$_MAINLOOP + 192
    frame #6: 0x000000010007bc68 ultrastardx`UMAIN_$$_MAIN + 2328
    frame #7: 0x000000010000a008 ultrastardx`PASCALMAIN + 104
    frame #8: 0x0000000100035670 ultrastardx`FPC_SysEntry + 32
    frame #9: 0x0000000100009f50 ultrastardx`FPC_SYSTEMMAIN + 80
    frame #10: 0x0000000100009f8c ultrastardx`main + 12
    frame #11: 0x000000010088508c dyld`start + 520
  thread #2
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x00000001000372d8 ultrastardx`CTHREADS_$$_INTRTLEVENTWAITFOR$PRTLEVENT + 40
    frame #3: 0x00000001000298a8 ultrastardx`SYSTEM_$$_RTLEVENTWAITFOR$PRTLEVENT + 24
    frame #4: 0x0000000100074524 ultrastardx`UCOMMON_$$_CONSOLEHANDLERFUNC$POINTER$$INT64 + 84
    frame #5: 0x000000010003695c ultrastardx`CTHREADS_$$_THREADMAIN$POINTER$$POINTER + 140
    frame #6: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #3, name = 'SDLTimer'
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000100c67c18 libSDL2-2.0.0.dylib`SDL_CondWaitTimeout_REAL + 148
    frame #3: 0x0000000100c67750 libSDL2-2.0.0.dylib`SDL_SemWaitTimeout_REAL + 80
    frame #4: 0x0000000100c122b0 libSDL2-2.0.0.dylib`SDL_TimerThread + 428
    frame #5: 0x0000000100c11dcc libSDL2-2.0.0.dylib`SDL_RunThread + 48
    frame #6: 0x0000000100c67370 libSDL2-2.0.0.dylib`RunThread + 12
    frame #7: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #4
    frame #0: 0x000000018fdf472c libsystem_kernel.dylib`__workq_kernreturn + 8
  thread #6
    frame #0: 0x000000018fdf472c libsystem_kernel.dylib`__workq_kernreturn + 8
  thread #8
    frame #0: 0x000000018fdf472c libsystem_kernel.dylib`__workq_kernreturn + 8
  thread #9, name = 'AMCP Logging Spool'
    frame #0: 0x000000018fdf28ec libsystem_kernel.dylib`semaphore_wait_trap + 8
    frame #1: 0x00000001988a5a2c caulk`caulk::mach::semaphore::wait_or_error() + 28
    frame #2: 0x00000001988897ac caulk`caulk::concurrent::details::worker_thread::run() + 56
    frame #3: 0x00000001988893cc caulk`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
    frame #4: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
* thread #10, name = 'AudioQueue thread', stop reason = EXC_BAD_INSTRUCTION (code=1, subcode=0x4f21fe14)
  * frame #0: 0x0000000100ab11b4 libswresample.4.dylib`___lldb_unnamed_symbol78 + 60
    frame #1: 0x0000000100ab1d44 libswresample.4.dylib`___lldb_unnamed_symbol93 + 528
    frame #2: 0x0000000100ab7db8 libswresample.4.dylib`___lldb_unnamed_symbol224 + 80
    frame #3: 0x0000000100ab7b30 libswresample.4.dylib`swr_convert + 524
    frame #4: 0x00000001000ffc1c ultrastardx`UAUDIODECODER_FFMPEG$_$TFFMPEGDECODESTREAM_$__$$_READDATA$PBYTEARRAY$LONGINT$$LONGINT + 284
    frame #5: 0x00000001000f63c4 ultrastardx`UAUDIOPLAYBACK_SOFTMIXER$_$TGENERICPLAYBACKSTREAM_$__$$_READDATA$PBYTEARRAY$LONGINT$$LONGINT + 708
    frame #6: 0x00000001000f57cc ultrastardx`UAUDIOPLAYBACK_SOFTMIXER$_$TAUDIOMIXERSTREAM_$__$$_READDATA$PBYTEARRAY$LONGINT$$LONGINT + 220
    frame #7: 0x00000001000fc080 ultrastardx`UAUDIOPLAYBACK_SDL_$$_SDLAUDIOCALLBACK$POINTER$PBYTEARRAY$LONGINT + 16
    frame #8: 0x0000000100c7ac1c libSDL2-2.0.0.dylib`outputCallback + 384
    frame #9: 0x000000019d5c71d8 AudioToolbox`ClientAudioQueue::CallOutputCallback(AudioQueueBuffer*) + 292
    frame #10: 0x000000019d5b1378 AudioToolbox`ClientAudioQueue::FetchAndDeliverPendingCallbacks(unsigned int) + 812
    frame #11: 0x000000019d5b0fbc AudioToolbox`_XCallbackNotificationsAvailable + 216
    frame #12: 0x000000019c48b18c libAudioToolboxUtility.dylib`mshMIGPerform + 264
    frame #13: 0x000000018fefd818 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 60
    frame #14: 0x000000018fefd6d4 CoreFoundation`__CFRunLoopDoSource1 + 604
    frame #15: 0x000000018fefbb68 CoreFoundation`__CFRunLoopRun + 2372
    frame #16: 0x000000018fefaa84 CoreFoundation`CFRunLoopRunSpecific + 600
    frame #17: 0x0000000100c7a7c4 libSDL2-2.0.0.dylib`audioqueue_thread + 1152
    frame #18: 0x0000000100c11dcc libSDL2-2.0.0.dylib`SDL_RunThread + 48
    frame #19: 0x0000000100c67370 libSDL2-2.0.0.dylib`RunThread + 12
    frame #20: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #11
    frame #0: 0x000000018fdf28ec libsystem_kernel.dylib`semaphore_wait_trap + 8
    frame #1: 0x00000001988a5a2c caulk`caulk::mach::semaphore::wait_or_error() + 28
    frame #2: 0x00000001988897ac caulk`caulk::concurrent::details::worker_thread::run() + 56
    frame #3: 0x00000001988893cc caulk`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
    frame #4: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #12, name = 'AQConverterThread'
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x000000019c4a7430 libAudioToolboxUtility.dylib`CADeprecated::CAGuard::Wait() + 60
    frame #3: 0x000000019d5b844c AudioToolbox`AQConverterManager::AQConverterThread::ConverterThreadEntry(void*) + 720
    frame #4: 0x000000019c4892fc libAudioToolboxUtility.dylib`CADeprecated::CAPThread::Entry(CADeprecated::CAPThread*) + 92
    frame #5: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #13, name = 'com.apple.audio.IOThread.client'
    frame #0: 0x000000018fdf28b0 libsystem_kernel.dylib`mach_msg_trap + 8
    frame #1: 0x000000018fdf2d20 libsystem_kernel.dylib`mach_msg + 76
    frame #2: 0x0000000191b426a0 CoreAudio`HALB_MachPort::SendSimpleMessageWithSimpleReply(unsigned int, unsigned int, int, int&, bool, unsigned int) + 104
    frame #3: 0x00000001919cfbb0 CoreAudio`HALC_ProxyIOContext::IOWorkLoop() + 3336
    frame #4: 0x00000001919ce8b0 CoreAudio`invocation function for block in HALC_ProxyIOContext::HALC_ProxyIOContext(unsigned int, unsigned int) + 100
    frame #5: 0x0000000191b9aab0 CoreAudio`HALB_IOThread::Entry(void*) + 88
    frame #6: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #15
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000100c67c80 libSDL2-2.0.0.dylib`SDL_CondWait_REAL + 20
    frame #3: 0x00000001000feddc ultrastardx`UAUDIODECODER_FFMPEG$_$TFFMPEGDECODESTREAM_$__$$_PARSE + 44
    frame #4: 0x00000001000feda4 ultrastardx`UAUDIODECODER_FFMPEG_$$_PARSETHREADMAIN$POINTER$$LONGINT + 20
    frame #5: 0x0000000100c11dcc libSDL2-2.0.0.dylib`SDL_RunThread + 48
    frame #6: 0x0000000100c67370 libSDL2-2.0.0.dylib`RunThread + 12
    frame #7: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #16
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000100c67c80 libSDL2-2.0.0.dylib`SDL_CondWait_REAL + 20
    frame #3: 0x00000001000feddc ultrastardx`UAUDIODECODER_FFMPEG$_$TFFMPEGDECODESTREAM_$__$$_PARSE + 44
    frame #4: 0x00000001000feda4 ultrastardx`UAUDIODECODER_FFMPEG_$$_PARSETHREADMAIN$POINTER$$LONGINT + 20
    frame #5: 0x0000000100c11dcc libSDL2-2.0.0.dylib`SDL_RunThread + 48
    frame #6: 0x0000000100c67370 libSDL2-2.0.0.dylib`RunThread + 12
    frame #7: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #17
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000100c67c80 libSDL2-2.0.0.dylib`SDL_CondWait_REAL + 20
    frame #3: 0x00000001000feddc ultrastardx`UAUDIODECODER_FFMPEG$_$TFFMPEGDECODESTREAM_$__$$_PARSE + 44
    frame #4: 0x00000001000feda4 ultrastardx`UAUDIODECODER_FFMPEG_$$_PARSETHREADMAIN$POINTER$$LONGINT + 20
    frame #5: 0x0000000100c11dcc libSDL2-2.0.0.dylib`SDL_RunThread + 48
    frame #6: 0x0000000100c67370 libSDL2-2.0.0.dylib`RunThread + 12
    frame #7: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #18
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000100c67c80 libSDL2-2.0.0.dylib`SDL_CondWait_REAL + 20
    frame #3: 0x00000001000feddc ultrastardx`UAUDIODECODER_FFMPEG$_$TFFMPEGDECODESTREAM_$__$$_PARSE + 44
    frame #4: 0x00000001000feda4 ultrastardx`UAUDIODECODER_FFMPEG_$$_PARSETHREADMAIN$POINTER$$LONGINT + 20
    frame #5: 0x0000000100c11dcc libSDL2-2.0.0.dylib`SDL_RunThread + 48
    frame #6: 0x0000000100c67370 libSDL2-2.0.0.dylib`RunThread + 12
    frame #7: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #19
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000100c67c80 libSDL2-2.0.0.dylib`SDL_CondWait_REAL + 20
    frame #3: 0x00000001000feddc ultrastardx`UAUDIODECODER_FFMPEG$_$TFFMPEGDECODESTREAM_$__$$_PARSE + 44
    frame #4: 0x00000001000feda4 ultrastardx`UAUDIODECODER_FFMPEG_$$_PARSETHREADMAIN$POINTER$$LONGINT + 20
    frame #5: 0x0000000100c11dcc libSDL2-2.0.0.dylib`SDL_RunThread + 48
    frame #6: 0x0000000100c67370 libSDL2-2.0.0.dylib`RunThread + 12
    frame #7: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #20
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000100c67c80 libSDL2-2.0.0.dylib`SDL_CondWait_REAL + 20
    frame #3: 0x00000001000feddc ultrastardx`UAUDIODECODER_FFMPEG$_$TFFMPEGDECODESTREAM_$__$$_PARSE + 44
    frame #4: 0x00000001000feda4 ultrastardx`UAUDIODECODER_FFMPEG_$$_PARSETHREADMAIN$POINTER$$LONGINT + 20
    frame #5: 0x0000000100c11dcc libSDL2-2.0.0.dylib`SDL_RunThread + 48
    frame #6: 0x0000000100c67370 libSDL2-2.0.0.dylib`RunThread + 12
    frame #7: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #21
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000100c67c80 libSDL2-2.0.0.dylib`SDL_CondWait_REAL + 20
    frame #3: 0x00000001000feddc ultrastardx`UAUDIODECODER_FFMPEG$_$TFFMPEGDECODESTREAM_$__$$_PARSE + 44
    frame #4: 0x00000001000feda4 ultrastardx`UAUDIODECODER_FFMPEG_$$_PARSETHREADMAIN$POINTER$$LONGINT + 20
    frame #5: 0x0000000100c11dcc libSDL2-2.0.0.dylib`SDL_RunThread + 48
    frame #6: 0x0000000100c67370 libSDL2-2.0.0.dylib`RunThread + 12
    frame #7: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #22
    frame #0: 0x000000018fdf606c libsystem_kernel.dylib`__semwait_signal + 8
    frame #1: 0x000000018fcfefc8 libsystem_c.dylib`nanosleep + 220
    frame #2: 0x0000000100c82820 libSDL2-2.0.0.dylib`SDL_Delay_REAL + 80
    frame #3: 0x00000001000ff238 ultrastardx`UAUDIODECODER_FFMPEG$_$TFFMPEGDECODESTREAM_$__$$_PARSELOOP$$BOOLEAN + 1048
    frame #4: 0x00000001000fee04 ultrastardx`UAUDIODECODER_FFMPEG$_$TFFMPEGDECODESTREAM_$__$$_PARSE + 84
    frame #5: 0x00000001000feda4 ultrastardx`UAUDIODECODER_FFMPEG_$$_PARSETHREADMAIN$POINTER$$LONGINT + 20
    frame #6: 0x0000000100c11dcc libSDL2-2.0.0.dylib`SDL_RunThread + 48
    frame #7: 0x0000000100c67370 libSDL2-2.0.0.dylib`RunThread + 12
    frame #8: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #23, name = 'com.apple.NSEventThread'
    frame #0: 0x000000018fdf28b0 libsystem_kernel.dylib`mach_msg_trap + 8
    frame #1: 0x000000018fdf2d20 libsystem_kernel.dylib`mach_msg + 76
    frame #2: 0x000000018fefd210 CoreFoundation`__CFRunLoopServiceMachPort + 372
    frame #3: 0x000000018fefb6c0 CoreFoundation`__CFRunLoopRun + 1180
    frame #4: 0x000000018fefaa84 CoreFoundation`CFRunLoopRunSpecific + 600
    frame #5: 0x0000000192bcf100 AppKit`_NSEventThread + 196
    frame #6: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #25
    frame #0: 0x000000018fdf472c libsystem_kernel.dylib`__workq_kernreturn + 8
  thread #26, name = 'CVDisplayLink'
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe30868 libsystem_pthread.dylib`_pthread_cond_wait + 1280
    frame #2: 0x00000001974db380 CoreVideo`CVDisplayLink::waitUntil(unsigned long long) + 324
    frame #3: 0x00000001974da460 CoreVideo`CVDisplayLink::runIOThread() + 488
    frame #4: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #27
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x00000001000372d8 ultrastardx`CTHREADS_$$_INTRTLEVENTWAITFOR$PRTLEVENT + 40
    frame #3: 0x00000001000298a8 ultrastardx`SYSTEM_$$_RTLEVENTWAITFOR$PRTLEVENT + 24
    frame #4: 0x00000001001ebd58 ultrastardx`CLASSES_$$_THREADFUNC$POINTER$$INT64 + 88
    frame #5: 0x000000010003695c ultrastardx`CTHREADS_$$_THREADMAIN$POINTER$$POINTER + 140
    frame #6: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #28
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000101b015cc libavcodec.60.dylib`___lldb_unnamed_symbol7232 + 188
    frame #3: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #29
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000101b015cc libavcodec.60.dylib`___lldb_unnamed_symbol7232 + 188
    frame #3: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #30
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000101b015cc libavcodec.60.dylib`___lldb_unnamed_symbol7232 + 188
    frame #3: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #31
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000101b015cc libavcodec.60.dylib`___lldb_unnamed_symbol7232 + 188
    frame #3: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #32
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000101b015cc libavcodec.60.dylib`___lldb_unnamed_symbol7232 + 188
    frame #3: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #33
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000101b015cc libavcodec.60.dylib`___lldb_unnamed_symbol7232 + 188
    frame #3: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #34
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000101b015cc libavcodec.60.dylib`___lldb_unnamed_symbol7232 + 188
    frame #3: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #35
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000101b015cc libavcodec.60.dylib`___lldb_unnamed_symbol7232 + 188
    frame #3: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #36
    frame #0: 0x000000018fdf6270 libsystem_kernel.dylib`__psynch_cvwait + 8
    frame #1: 0x000000018fe3083c libsystem_pthread.dylib`_pthread_cond_wait + 1236
    frame #2: 0x0000000101b015cc libavcodec.60.dylib`___lldb_unnamed_symbol7232 + 188
    frame #3: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #37, name = 'com.apple.audio.IOThread.client'
    frame #0: 0x000000018fdf28b0 libsystem_kernel.dylib`mach_msg_trap + 8
    frame #1: 0x000000018fdf2d20 libsystem_kernel.dylib`mach_msg + 76
    frame #2: 0x0000000191b426a0 CoreAudio`HALB_MachPort::SendSimpleMessageWithSimpleReply(unsigned int, unsigned int, int, int&, bool, unsigned int) + 104
    frame #3: 0x00000001919cfbb0 CoreAudio`HALC_ProxyIOContext::IOWorkLoop() + 3336
    frame #4: 0x00000001919ce8b0 CoreAudio`invocation function for block in HALC_ProxyIOContext::HALC_ProxyIOContext(unsigned int, unsigned int) + 100
    frame #5: 0x0000000191b9aab0 CoreAudio`HALB_IOThread::Entry(void*) + 88
    frame #6: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #38
    frame #0: 0x000000018fdf606c libsystem_kernel.dylib`__semwait_signal + 8
    frame #1: 0x000000018fcfefc8 libsystem_c.dylib`nanosleep + 220
    frame #2: 0x0000000100c82820 libSDL2-2.0.0.dylib`SDL_Delay_REAL + 80
    frame #3: 0x00000001000ff238 ultrastardx`UAUDIODECODER_FFMPEG$_$TFFMPEGDECODESTREAM_$__$$_PARSELOOP$$BOOLEAN + 1048
    frame #4: 0x00000001000fee04 ultrastardx`UAUDIODECODER_FFMPEG$_$TFFMPEGDECODESTREAM_$__$$_PARSE + 84
    frame #5: 0x00000001000feda4 ultrastardx`UAUDIODECODER_FFMPEG_$$_PARSETHREADMAIN$POINTER$$LONGINT + 20
    frame #6: 0x0000000100c11dcc libSDL2-2.0.0.dylib`SDL_RunThread + 48
    frame #7: 0x0000000100c67370 libSDL2-2.0.0.dylib`RunThread + 12
    frame #8: 0x000000018fe3026c libsystem_pthread.dylib`_pthread_start + 148
  thread #39
    frame #0: 0x0000000000000000
s09bQ5 commented 1 year ago

The exception appears to happen in this line (since it matches the exception subcode and it is the only occurrence in FFmpeg): https://github.com/FFmpeg/FFmpeg/blob/master/libswresample/aarch64/audio_convert_neon.S#L87

I have no idea why the Apple silicon doesn't like that instruction. It had to execute the same instruction with other register numbers to get to that line. Maybe this exception is generated also when trying to convert NaN or infinity to an integer? What is the contents of the v16 register in that thread after it crashed?

umxprime commented 1 year ago

For this instruction I have

(lldb) p $v16
(unsigned char __attribute__((ext_vector_type(16)))) $0 = (0x95, 0x79, 0x81, 0x3f, 0x82, 0xc7, 0x71, 0x3f, 0xac, 0xc0, 0x54, 0x3f, 0xb3, 0x87, 0x3b, 0x3f)
umxprime commented 1 year ago

Got another one given I let the preview plays in song section screen

Process 26491 stopped
* thread #8, name = 'AudioQueue thread', stop reason = EXC_BAD_INSTRUCTION (code=1, subcode=0x4f21fc67)
    frame #0: 0x0000000100ab1208 libswresample.4.dylib`___lldb_unnamed_symbol78 + 144
libswresample.4.dylib`___lldb_unnamed_symbol78:
->  0x100ab1208 <+144>: fcvtzs.4s v7, v3, #0x1f
    0x100ab120c <+148>: st1.4s { v23 }, [x0], #16
    0x100ab1210 <+152>: b.ne   0x100ab11ac               ; <+52>
    0x100ab1214 <+156>: ands   x2, x2, #0xf
Target 0: (ultrastardx) stopped.
(lldb) p $v3
(unsigned char __attribute__((ext_vector_type(16)))) $2 = (0x21, 0xe6, 0x70, 0x3f, 0xcf, 0x53, 0x7d, 0x3f, 0x7f, 0x87, 0x83, 0x3f, 0xd9, 0xfa, 0x7d, 0x3f)
s09bQ5 commented 1 year ago

On an i.MX8M the fcvtzs instruction converts 0x95, 0x79, 0x81, 0x3f, 0x82, 0xc7, 0x71, 0x3f, 0xac, 0xc0, 0x54, 0x3f, 0xb3, 0x87, 0x3b, 0x3f to 0xFF 0xFF 0xFF 0x7F 0x00 0xC1 0xE3 0x78 0x00 0x56 0x60 0x6A 0x80 0xD9 0xC3 0x5D and 0x21, 0xe6, 0x70, 0x3f, 0xcf, 0x53, 0x7d, 0x3f, 0x7f, 0x87, 0x83, 0x3f, 0xd9, 0xfa, 0x7d, 0x3f to 0x80 0x10 0x73 0x78 0x80 0xE7 0xA9 0x7E 0xFF 0xFF 0xFF 0x7F 0x80 0x6C 0xFD 0x7E. So in both cases there was a floating point number > 1 that had to be clipped to 0x7FFFFFFF.

Here the Free Pascal runtime enables floating point exceptions. The i.MX8M does not support these exceptions. This page confirms that macOS delivers floating point exceptions with SIGILL instead of with SIGFPE. We could try to use the SetExceptionMask function to disable the exceptions, but I don't know if the mask is inherited to new threads.

s09bQ5 commented 1 year ago

Hm, we already do disable floating point exceptions here and here. Maybe inheritance of the mask really is the problem.

umxprime commented 1 year ago

IIRC FPE works per thread and I remember that I had to handle such case given I had to do some signal processing with intel primitives or Apple Accelerate framework

s09bQ5 commented 1 year ago

We don't create that thread. I'm unsure if we should change the exception mask permanently or revert it every time we return from the audio callback...

s09bQ5 commented 1 year ago

@umxprime, please try https://github.com/s09bQ5/USDX/tree/fpu-exceptions

umxprime commented 1 year ago

So far so good with your patch 😍