MusicPlayerDaemon / MPD

Music Player Daemon
https://www.musicpd.org/
GNU General Public License v2.0
2.2k stars 350 forks source link

OSXAudio causes SEGV only when daemonized #1879

Closed Sean-Der closed 7 months ago

Sean-Der commented 1 year ago

Bug report

Describe the bug

When launching as a daemon MPD crashes.

0   libsystem_trace.dylib                  0x18d2e323c _os_log_preferences_refresh + 68
1   libsystem_trace.dylib                  0x18d2e3c9c os_log_type_enabled + 712
2   CoreFoundation                         0x18d646728 _CFBundleDlfcnCheckLoaded + 172
3   CoreFoundation                         0x18d6f1d0c _CFBundleLoadExecutableAndReturnError + 136
4   AudioToolboxCore                       0x18f75ff8c APComponent_FromBundle_Loadable::ResolveFactoryFunction() + 68
5   AudioToolboxCore                       0x18f75ef6c APComponent::newInstance(unsigned int, bool, void (OpaqueAudioComponentInstance*, int) block_pointer) + 324
6   AudioToolboxCore                       0x18f8942fc instantiate(OpaqueAudioComponent*, unsigned int, bool, void (OpaqueAudioComponentInstance*, int) block_pointer) + 428
7   AudioToolboxCore                       0x18f89481c __AudioComponentInstanceNew_block_invoke + 120
8   AudioToolboxCore                       0x18f6d1058 Synchronously + 132
9   AudioToolboxCore                       0x18f8945a0 AudioComponentInstanceNew + 248
10  mpd                                    0x1048fbeb8 OSXOutput::Enable() + 112
11  mpd                                    0x1048eeae8 FilteredAudioOutput::Enable() + 36
12  mpd                                    0x1048f1508 AudioOutputControl::InternalEnable() + 88
13  mpd                                    0x1048f117c AudioOutputControl::Task() + 228
14  mpd                                    0x1048cd9dc Thread::ThreadProc(void*) + 32
15  libsystem_pthread.dylib                0x18d57f034 _pthread_start + 136
16  libsystem_pthread.dylib                0x18d579e3c thread_start + 8

If I launch with mpd --no-daemon it works.

I am running macOS Sonoma. I can't think of anything else unique about my setup yet. This didn't happen before.

Expected Behavior

Playback

Actual Behavior

SEGV

Version

Music Player Daemon 0.23.14 (0.23.14)
Copyright 2003-2007 Warren Dukes <warren.dukes@gmail.com>
Copyright 2008-2021 Max Kellermann <max.kellermann@gmail.com>
This is free software; see the source for copying conditions.  There is NO
warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Database plugins:
 simple proxy upnp

Storage plugins:
 local nfs curl

Neighbor plugins:
 upnp

Decoders plugins:
 [mpg123] mp3
 [vorbis] ogg oga
 [oggflac] ogg oga
 [flac] flac
 [opus] opus ogg oga
 [sndfile] wav aiff aif au snd paf iff svx sf voc w64 pvf xi htk caf sd2
 [dsdiff] dff
 [dsf] dsf
 [hybrid_dsd] m4a
 [faad] aac
 [wavpack] wv
 [fluidsynth] mid
 [gme] ay gbs gym hes kss nsf nsfe rsn sap spc vgm vgz
 [ffmpeg] 16sv 3g2 3gp 4xm 8svx aa3 aac ac3 adx afc aif aifc aiff al alaw amr anim apc ape asf atrac au aud avi avm2 avs bap bfi c93 cak cin cmv cpk daud dct divx dts dv dvd dxa eac3 film flac flc fli fll flx flv g726 gsm gxf iss m1v m2v m2t m2ts m4a m4b m4v mad mj2 mjpeg mjpg mka mkv mlp mm mmf mov mp+ mp1 mp2 mp3 mp4 mpc mpeg mpg mpga mpp mpu mve mvi mxf nc nsv nut nuv oga ogm ogv ogx oma ogg omg opus psp pva qcp qt r3d ra ram rl2 rm rmvb roq rpl rvc shn smk snd sol son spx str swf tak tgi tgq tgv thp ts tsp tta xa xvid uv uv2 vb vid vob voc vp6 vmd wav webm wma wmv wsaud wsvga wv wve rtp:// rtsp:// rtsps://
 [pcm]

Filters:
 libsamplerate soxr

Tag plugins:
 id3tag

Output plugins:
 shout null fifo pipe ao openal osx httpd snapcast recorder

Encoder plugins:
 null vorbis opus lame wave flac

Archive plugins:
 [bz2] bz2

Input plugins:
 file archive curl ffmpeg nfs

Playlist plugins:
 extm3u m3u pls xspf asx rss flac cue embcue

Protocols:
 file:// ftp:// ftps:// gopher:// hls+http:// hls+https:// http:// https:// mmsh:// mmst:// nfs:// rtmp:// rtmps:// rtmpt:// rtmpts:// rtp:// rtsp:// rtsps:// smb:// srtp://

Other features:
 icu ipv6 tcp un

Configuration

music_directory         "~/Music"
playlist_directory      "~/.mpd/playlists"
db_file                 "~/.mpd/mpd.db"
log_file                "~/.mpd/mpd.log"
pid_file                "~/.mpd/mpd.pid"
state_file              "~/.mpd/mpdstate"
auto_update             "yes"
auto_update_depth       "2"
follow_outside_symlinks "yes"
follow_inside_symlinks  "yes"

audio_output {
    type                  "osx"
    name                  "mpd"
    mixer_type            "software"
}

decoder {
    plugin                "fluidsynth"
    soundfont             "/Users/sean/Music/MIDI/GravisUltrasound.sf2"
}

bind_to_address         "127.0.0.1"
port                    "6600"

Log

None

Sean-Der commented 1 year ago

I am able to get it in lldb

(lldb) bt
* thread #9, name = 'output:mpd', stop reason = EXC_BAD_ACCESS (code=1, address=0x10c114a64)
  * frame #0: 0x000000018d2e323c libsystem_trace.dylib`_os_log_preferences_refresh + 68
    frame #1: 0x000000018d2e3c9c libsystem_trace.dylib`os_log_type_enabled + 712
    frame #2: 0x000000018d646728 CoreFoundation`_CFBundleDlfcnCheckLoaded + 172
    frame #3: 0x000000018d6f1d0c CoreFoundation`_CFBundleLoadExecutableAndReturnError + 136
    frame #4: 0x000000018f75ff8c AudioToolboxCore`APComponent_FromBundle_Loadable::ResolveFactoryFunction() + 68
    frame #5: 0x000000018f75ef6c AudioToolboxCore`APComponent::newInstance(unsigned int, bool, void (OpaqueAudioComponentInstance*, int) block_pointer) + 324
    frame #6: 0x000000018f8942fc AudioToolboxCore`instantiate(OpaqueAudioComponent*, unsigned int, bool, void (OpaqueAudioComponentInstance*, int) block_pointer) + 428
    frame #7: 0x000000018f89481c AudioToolboxCore`__AudioComponentInstanceNew_block_invoke + 120
    frame #8: 0x000000018f6d1058 AudioToolboxCore`Synchronously + 132
    frame #9: 0x000000018f8945a0 AudioToolboxCore`AudioComponentInstanceNew + 248
    frame #10: 0x0000000104f1feb8 mpd`OSXOutput::Enable() + 112
    frame #11: 0x0000000104f12ae8 mpd`FilteredAudioOutput::Enable() + 36
    frame #12: 0x0000000104f15508 mpd`AudioOutputControl::InternalEnable() + 88
    frame #13: 0x0000000104f1517c mpd`AudioOutputControl::Task() + 228
    frame #14: 0x0000000104ef19dc mpd`Thread::ThreadProc(void*) + 32
    frame #15: 0x000000018d57f034 libsystem_pthread.dylib`_pthread_start + 136
Sean-Der commented 1 year ago

Crashes with ao output as well. Seems unlikely to be output specific!

Thread 5 Crashed:: output:mpd
0   libsystem_trace.dylib                  0x18d2e323c _os_log_preferences_refresh + 68
1   libsystem_trace.dylib                  0x18d2e3c9c os_log_type_enabled + 712
2   CoreFoundation                         0x18d646728 _CFBundleDlfcnCheckLoaded + 172
3   CoreFoundation                         0x18d6f1d0c _CFBundleLoadExecutableAndReturnError + 136
4   AudioToolboxCore                       0x18f75ff8c APComponent_FromBundle_Loadable::ResolveFactoryFunction() + 68
5   AudioToolboxCore                       0x18f75ef6c APComponent::newInstance(unsigned int, bool, void (OpaqueAudioComponentInstance*, int) block_pointer) + 324
6   AudioToolboxCore                       0x18f8942fc instantiate(OpaqueAudioComponent*, unsigned int, bool, void (OpaqueAudioComponentInstance*, int) block_pointer) + 428
7   AudioToolboxCore                       0x18f89481c __AudioComponentInstanceNew_block_invoke + 120
8   AudioToolboxCore                       0x18f6d1058 Synchronously + 132
9   AudioToolboxCore                       0x18f8945a0 AudioComponentInstanceNew + 248
10  libmacosx.so                           0x100d922b0 ao_plugin_open + 84
11  libao.4.dylib                          0x10122c854 _open_device + 1556
12  mpd                                    0x100c40190 AoOutput::Open(AudioFormat&) + 140
13  mpd                                    0x100c36cac FilteredAudioOutput::OpenOutputAndConvert(AudioFormat) + 80
14  mpd                                    0x100c3a1c4 AudioOutputControl::InternalOpen2(AudioFormat) + 268
15  mpd                                    0x100c396a8 AudioOutputControl::InternalOpen(AudioFormat, MusicPipe const&) + 144
16  mpd                                    0x100c39198 AudioOutputControl::Task() + 256
17  mpd                                    0x100c159dc Thread::ThreadProc(void*) + 32
18  libsystem_pthread.dylib                0x18d57f034 _pthread_start + 136
19  libsystem_pthread.dylib                0x18d579e3c thread_start + 8
MaxKellermann commented 1 year ago

Unfortunately, I cannot help with this bug because I don't have a Mac. Let's hope somebody else drops by who happens to have one and wants to help.

What you can do meanwhile is try to bisect the bug - to see which commit introduces it.

MaxKellermann commented 7 months ago

Apparently, nobody is interested in providing macOS support for MPD; and since @Sean-Der is not interested in doing a bisect, I have no chance but to close this (and eventually remove all macOS specific code from MPD).