MusicPlayerDaemon / MPD

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

MPD crashes on startup with PipeWire 0.3.53 #1558

Closed YHNdnzj closed 2 years ago

YHNdnzj commented 2 years ago

Bug report

Describe the bug

After upgrading pipewire to 0.3.53, mpd dumps core every time on startup after loading decoder. Previously it starts and plays fine, although it can't remember the volume as to #1484.

Switching output type to pulse solves both of the problems.

Version

Music Player Daemon 0.23.7 (0.23.7)
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 udisks nfs curl

Neighbor plugins:
 upnp udisks

Decoders plugins:
 [mad] mp3 mp2
 [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
 [audiofile] wav au aiff aif
 [dsdiff] dff
 [dsf] dsf
 [hybrid_dsd] m4a
 [faad] aac
 [mpcdec] mpc
 [wavpack] wv
 [openmpt] mptm mod s3m xm it 669 amf ams c67 dbm digi dmf dsm dtm far imf ice j2b m15 mdl med mms mt2 mtm nst okt plm psm pt36 ptm sfx sfx2 st26 stk stm stp ult wow gdm mo3 oxm umx xpk ppm mmcmp
 [modplug] 669 amf ams dbm dfm dsm far it med mdl mod mtm mt2 okt s3m stm ult umx xm
 [mikmod] amf dsm far gdm imf it med mod mtm s3m stm stx ult uni xm
 [sidplay] sid mus str prg P00
 [wildmidi] mid
 [fluidsynth] mid
 [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://
 [gme] ay gbs gym hes kss nsf nsfe rsn sap spc vgm vgz
 [pcm]

Filters:
 libsamplerate soxr

Tag plugins:
 id3tag

Output plugins:
 shout null fifo pipe alsa ao oss openal solaris pipewire pulse jack httpd snapcast recorder

Encoder plugins:
 null vorbis opus lame twolame wave flac

Archive plugins:
 [bz2] bz2
 [zzip] zip
 [iso] iso

Input plugins:
 file io_uring archive alsa qobuz curl ffmpeg nfs mms cdio_paranoia

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

Protocols:
 file:// alsa:// cdda:// ftp:// ftps:// gopher:// hls+http:// hls+https:// http:// https:// mms:// mmsh:// mmst:// mmsu:// nfs:// qobuz:// rtmp:// rtmpe:// rtmps:// rtmpt:// rtmpte:// rtmpts:// rtp:// rtsp:// rtsps:// scp:// sftp:// smb:// srtp://

Other features:
 avahi dbus udisks epoll icu inotify ipv6 systemd tcp un

Backtrace using GDB

#0  __strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:284
#1  0x00005564fcbdfcde in  ()
#2  0x00007fb430717b4f in node_event_param (object=0x7fb400047ef0, seq=<optimized out>, id=<optimized out>, index=<optimized out>, next=<optimized out>, param=0x7fb4163f7a90)
    at ../pipewire/src/pipewire/stream.c:1308
        _f = <optimized out>
        _res = true
        _list = 0x7fb400047f58
        _s = 0x7fb400047f58
        _cursor = {link = {next = 0x7fb400047f58, prev = 0x7fb4000490f0}, cb = {funcs = 0x0, data = 0x0}, removed = 0x0, priv = 0x0}
        _ci = <optimized out>
        _count = <optimized out>
        c = 0x7fb3f8003bf0
        obj = 0x7fb4163f7a90
        value = {f = 1, d = 5.2635442471208903e-315, b = false}
        values = 0x7fb4163f74c0
        i = <optimized out>
        prop = 0x7fb4163f7aa0
        n_values = <optimized out>
        stream = 0x7fb400047ef0
        __func__ = "node_event_param"
#3  0x00007fb4306f8df1 in result_node_params (data=0x7fb4163f9980, seq=<optimized out>, res=<optimized out>, type=<optimized out>, result=0x7fb4163f7640) at ../pipewire/src/pipewire/impl-node.c:1924
        r = 0x7fb4163f7640
        d = 0x7fb4163f9980
        impl = 0x7fb4000947b0
#4  0x00007fb41c31c51f in convert_result (data=0x7fb400077a98, seq=0, res=0, type=2, result=0x7fb4163f7640) at ../pipewire/spa/plugins/audioconvert/audioadapter.c:932
        _f = <optimized out>
        _res = true
        _l = 0x7fb400077f70
        _h = <optimized out>
        _t = 0x7fb400077f70
        this = 0x7fb400077a98
        __func__ = "convert_result"
#5  0x00007fb41c32f139 in impl_node_enum_params (object=0x7fb400077f98, seq=<optimized out>, id=2, start=<optimized out>, num=<optimized out>, filter=<optimized out>)
    at ../pipewire/spa/plugins/audioconvert/audioconvert.c:742
        _f = <optimized out>
        _res = true
        _l = 0x7fb4000784f0
        _h = <optimized out>
        _t = 0x7fb4163f8760
        this = 0x7fb400077f98
        param = <optimized out>
        b = {data = 0x7fb4163f76e0, size = 4096, _padding = 0, state = {offset = 1888, flags = 0, frame = 0x0}, callbacks = {funcs = 0x0, data = 0x0}}
        buffer = "\250\003\000\000\017\000\000\000\002\000\004\000\002\000\000\000\003\000\001\000\000\000\000\000\004\000\000\000\006\000\000\000\000\000\200?\000\000\000\000\004\000\001\000\000\000\000\000\004\000\000\000\002", '\000' <repeats 11 times>, "\b\000\001\000\000\000\000\000\020\000\000\000\r\000\000\000\004\000\000\000\006\000\000\000m\022\203=m\022\203=\v\000\001\000\000\000\000\000\020\000\000\000\r\000\000\000\004\000\000\000\003\000\000\000\003\000\000\000\004\000\000\000\017\000\001\000\000\000\000\000\004\000\000\000\002", '\000' <repeats 11 times>, "\020\000\001\000\000\000\000\000\b\000\000\000\r\000\000\000\004\000\000\000\006\000\000\000\f\000\001\000\000\000\000\000\004\000\000\000\002", '\000' <repeats 11 times>...
        result = {id = 2, index = 0, next = 1, param = 0x7fb4163f7a90}
        count = <optimized out>
        __func__ = "impl_node_enum_params"
#6  0x00007fb41c357cc9 in spa_node_enum_params_sync (builder=0x7fb4163f8890, param=0x7fb4163f8830, filter=0x0, index=0x7fb4163f8828, id=2, node=0x7fb400077fb0) at ../pipewire/spa/include/spa/node/utils.h:78
        _f = <optimized out>
        _res = -95
        _n = 0x7fb400077fb0
        data = {builder = 0x7fb4163f8890, data = {id = 0, index = 0, next = 0, param = 0x0}}
        listener = {link = {next = 0x7fb4000784f0, prev = 0x7fb400077d78}, cb = {funcs = 0x7fb41c37aca0 <node_events>, data = 0x7fb4163f8740}, removed = 0x0, priv = 0x0}
        res = <optimized out>
        res = <optimized out>
#7  follower_enum_params.constprop.0 (this=this@entry=0x7fb400077a98, id=id@entry=2, idx=idx@entry=2, result=result@entry=0x7fb4163f8820, filter=filter@entry=0x0, builder=builder@entry=0x7fb4163f8890) at ../pipewire/spa/plugins/audioconvert/audioadapter.c:124
        res = <optimized out>
#8  0x00007fb41c31d101 in impl_node_enum_params (object=<optimized out>, seq=0, id=<optimized out>, start=0, num=4294967295, filter=0x0) at ../pipewire/spa/plugins/audioconvert/audioadapter.c:174
        this = <optimized out>
        buffer = "(\001\000\000\017\000\000\000\001\000\004\000\001\000\000\000\002\000\000\000\000\000\000\000\016\000\000\000\b\000\000\000dither.method\000\000\000\a\000\000\000\000\000\000\000\025\000\000\000\b\000\000\000The dithering method\000\000\000\000\003\000\000\000\000\000\000\000\005\000\000\000\b\000\000\000none\000\000\000\000\006\000\000\000\000\000\000\000\004\000\000\000\002\000\000\000\001\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\230\000\000\000\016\000\000\000\005\000\000\000\b\000\000\000none\000\000\000\000\t\000\000\000\b\000\000\000Disabled\000\000\000\000\000\000\000\000\f\000\000\000\b\000\000\000"...
        b = {b = {data = 0x7fb4163f88d0, size = 4096, _padding = 0, state = {offset = 0, flags = 0, frame = 0x0}, callbacks = {funcs = 0x7fb41c376330 <spa_pod_dynamic_builder_callbacks.8.lto_priv>, data = 0x7fb4163f8890}}, data = 0x7fb4163f88d0, extend = 4096, _padding = 32692}
        result = {id = 2, index = 0, next = 0, param = 0x7fb4163f88d0}
        count = 0
        res = <optimized out>
        __func__ = "impl_node_enum_params"
#9  0x00007fb4306fa2e0 in pw_impl_node_for_each_param (node=0x7fb4000947b0, seq=<optimized out>, param_id=2, index=0, max=4294967295, filter=0x0, callback=0x7fb4307172c0 <node_event_param>, data=0x7fb400047ef0) at ../pipewire/src/pipewire/impl-node.c:2006
        _f = <optimized out>
        _res = -95
        _n = <optimized out>
        res = <optimized out>
        impl = 0x7fb4000947b0
        user_data = {impl = 0x7fb4000947b0, data = 0x7fb400047ef0, callback = 0x7fb4307172c0 <node_event_param>, seq = 0, count = 0, cache = 1}
        listener = {link = {next = 0x7fb400077f70, prev = 0x7fb400094d40}, cb = {funcs = 0x7fb430765220 <node_events>, data = 0x7fb4163f9980}, removed = 0x0, priv = 0x0}
        pi = 0x7fb400094890
        __func__ = "pw_impl_node_for_each_param"
        node_events = {version = 0, info = 0x0, port_info = 0x0, result = 0x7fb4306f8da0 <result_node_params>, event = 0x0}
#10 0x00007fb430718e7d in node_event_info (info=<optimized out>, data=<optimized out>) at ../pipewire/src/pipewire/stream.c:1329
        i = 2
        stream = 0x7fb400047ef0
        impl = 0x7fb400047ef0
#11 node_event_info (data=0x7fb400047ef0, info=0x7fb400094808) at ../pipewire/src/pipewire/stream.c:1318
        stream = 0x7fb400047ef0
        impl = 0x7fb400047ef0
#12 0x00007fb4306ecf03 in emit_info_changed (node=node@entry=0x7fb4000947b0, flags_changed=flags_changed@entry=false) at ../pipewire/src/pipewire/impl-node.c:260
        _f = <optimized out>
        _res = true
        _list = 0x7fb400094de0
        _s = 0x7fb400094de0
        _cursor = {link = {next = 0x7fb400094de0, prev = 0x7fb400047fa0}, cb = {funcs = 0x0, data = 0x0}, removed = 0x0, priv = 0x0}
        _ci = <optimized out>
        _count = <optimized out>
#13 0x00007fb4306f57e6 in node_info (data=0x7fb4000947b0, info=0x7fb400077e00) at ../pipewire/src/pipewire/impl-node.c:1407
        node = 0x7fb4000947b0
        changed_ids = {2, 0 <repeats 31 times>}
        n_changed_ids = 1
        flags_changed = false
        __func__ = "node_info"
#14 0x00007fb41c32360e in emit_node_info (this=0x7fb400077a98, full=<optimized out>) at ../pipewire/spa/plugins/audioconvert/audioadapter.c:276
        _f = <optimized out>
        _res = true
        _l = 0x7fb400077f70
        _h = <optimized out>
        _t = 0x7fb400077f70
        i = <optimized out>
        old = <optimized out>
        __func__ = "emit_node_info"
#15 0x00007fb41c328b1e in emit_node_info (this=this@entry=0x7fb400077f98, full=full@entry=false) at ../pipewire/spa/plugins/audioconvert/audioconvert.c:256
        _f = <optimized out>
        _res = true
        _l = 0x7fb4000784f0
        _h = <optimized out>
        _t = 0x7fb4000784f0
        old = <optimized out>
        i = <optimized out>
#16 0x00007fb41c337122 in impl_node_set_param (object=0x7fb400077f98, id=<optimized out>, flags=<optimized out>, param=<optimized out>) at ../pipewire/spa/plugins/audioconvert/audioconvert.c:1077
        info = {media_type = 1, media_subtype = 0, info = {raw = {format = 373272888, flags = 32692, rate = 0, channels = 0, position = {373272888, 32692, 48, 48, 373271984, 32692, 373271744, 32692, 3878871552, 2276729028, 373271760, 32692, 497432031, 32692, 373272688, 32692, 497432031, 32692, 373272696, 32692, 0, 0, 373272696, 32692, 0 <repeats 32 times>, 497432031, 32692, 373272976, 32692, 373272784, 32692, 373272752, 32692}}, dsp = {format = 373272888}, iec958 = {codec = 373272888, flags = 32692, rate = 0}, dsd = {bitorder = (unknown: 0x163fb138), flags = 32692, interleave = 0, rate = 0, channels = 373272888, position = {32692, 48, 48, 373271984, 32692, 373271744, 32692, 3878871552, 2276729028, 373271760, 32692, 497432031, 32692, 373272688, 32692, 497432031, 32692, 373272696, 32692, 0, 0, 373272696, 32692, 0 <repeats 32 times>, 497432031, 32692, 373272976, 32692, 373272784, 32692, 373272752, 32692, 44}}}}
        direction = SPA_DIRECTION_INPUT
        control = false
        infop = <optimized out>
        format = 0x0
        mode = SPA_PARAM_PORT_CONFIG_MODE_none
        monitor = false
        res = <optimized out>
        this = 0x7fb400077f98
        __func__ = "impl_node_set_param"
#17 0x00007fb41c32263d in impl_node_set_param (object=0x7fb400077a98, id=2, flags=0, param=0x7fb40006a698) at ../pipewire/spa/plugins/audioconvert/audioadapter.c:659
        _f = <optimized out>
        _res = -95
        _n = <optimized out>
        res = 0
        res2 = 0
        this = 0x7fb400077a98
        info = {media_type = 0, media_subtype = 0, info = {raw = {format = SPA_AUDIO_FORMAT_UNKNOWN, flags = 0, rate = 0, channels = 0, position = {0 <repeats 64 times>}}, dsp = {format = SPA_AUDIO_FORMAT_UNKNOWN}, iec958 = {codec = SPA_AUDIO_IEC958_CODEC_UNKNOWN, flags = 0, rate = 0}, dsd = {bitorder = SPA_PARAM_BITORDER_unknown, flags = 0, interleave = 0, rate = 0, channels = 0, position = {0 <repeats 64 times>}}}}
        __func__ = "impl_node_set_param"
#18 0x00007fb41c3c9b9b in client_node_set_param (_data=0x7fb4000956e8, id=2, flags=0, param=0x7fb40006a698) at ../pipewire/src/modules/module-client-node/remote-node.c:443
        _f = <optimized out>
        _res = -95
        _n = <optimized out>
        data = 0x7fb4000956e8
        proxy = <optimized out>
        res = <optimized out>
        __func__ = "client_node_set_param"
#19 0x00007fb41c3d8e35 in client_node_demarshal_set_param (data=<optimized out>, msg=<optimized out>) at ../pipewire/src/modules/module-client-node/protocol-native.c:420
        _f = <optimized out>
        _res = true
        _list = 0x7fb4000956c8
        _s = 0x7fb4000956c8
        _cursor = {link = {next = 0x7fb4000956c8, prev = 0x7fb400095780}, cb = {funcs = 0x0, data = 0x0}, removed = 0x0, priv = 0x0}
        _ci = <optimized out>
        _count = <optimized out>
        proxy = <optimized out>
        prs = {data = 0x7fb40006a670, size = 144, _padding = 0, state = {offset = 144, flags = 0, frame = 0x0}}
        id = 2
        flags = 0
        param = 0x7fb40006a698
#20 0x00007fb41da3ff84 in process_remote (impl=impl@entry=0x7fb400060460) at ../pipewire/src/modules/module-protocol-native.c:915
        proxy = 0x7fb400095670
        demarshal = <optimized out>
        marshal = <optimized out>
        msg = 0x7fb400072678
        conn = 0x7fb400060520
        this = 0x7fb40005f380
        res = 1
        __func__ = "process_remote"
#21 0x00007fb41da40620 in on_remote_data (data=0x7fb400060460, fd=31, mask=1) at ../pipewire/src/modules/module-protocol-native.c:949
        impl = 0x7fb400060460
        this = 0x7fb40005f380
        core_proxy = 0x7fb40005f380
        conn = 0x7fb400060520
        context = <optimized out>
        loop = 0x7fb400000ee0
        res = 0
        __func__ = "on_remote_data"
#22 0x00007fb433251e4d in loop_iterate (object=<optimized out>, timeout=<optimized out>) at ../pipewire/spa/plugins/support/loop.c:430
        s = <optimized out>
        __clframe = {__cancel_routine = <optimized out>, __cancel_arg = <synthetic pointer>, __do_it = 1, __cancel_type = <optimized out>}
        impl = <optimized out>
        ep = {{events = 1, data = 0x7fb400072740}, {events = 0, data = 0x0} <repeats 31 times>}
        e = <optimized out>
        i = 0
        nfds = <optimized out>
        __func__ = "loop_iterate"
#23 0x00007fb43071d22a in do_loop (user_data=0x7fb400000dd0) at ../pipewire/src/pipewire/thread-loop.c:253
        _f = <optimized out>
        _res = -95
        _o = <optimized out>
        this = 0x7fb400000dd0
        __func__ = "do_loop"
#24 0x00007fb42de8c54d in start_thread (arg=<optimized out>) at pthread_create.c:442
        ret = <optimized out>
        pd = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140411444119104, 5275462787120653046, 140411452506446, 0, 140411452506447, 140411435728896, -5305775775316811018, -5305681652648484106}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
#25 0x00007fb42df11874 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:100

Configuration

https://github.com/YHNdnzj/dotfiles/blob/master/mpd/.config/mpd/mpd.conf

MaxKellermann commented 2 years ago

Your backtrace shows that the crash occurs inside a thread created by libpipewire, and only libpipewire code is involved here, nothing MPD specific. This doesn't look like a MPD bug, but a PipeWire bug. Sorry, I can't help.

MaxKellermann commented 2 years ago

See also https://github.com/MusicPlayerDaemon/MPD/issues/1376 and https://github.com/MusicPlayerDaemon/MPD/issues/1464 for other PipeWire crash bugs mistakenly reported here.

YHNdnzj commented 2 years ago

Your backtrace shows that the crash occurs inside a thread created by libpipewire, and only libpipewire code is involved here, nothing MPD specific. This doesn't look like a MPD bug, but a PipeWire bug. Sorry, I can't help.

Thanks for the quick response. Just checked that someone has created an issue in PipeWire's repo (https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2488). I'll keep track of that instead.

saivert commented 2 years ago

The crash is caused by this code in MPD:

    static void ControlInfo(void *data,
                uint32_t id,
                const struct pw_stream_control *control) noexcept {
        auto &o = *(PipeWireOutput *)data;
        if (StringIsEqual(control->name, "Channel Volumes"))
            o.ControlInfo(control);
    }

control->name can now be NULL for some reason. This is a regression or a breaking change in API on pipewire's side. A possible fix would be to compare against id instead:

if (id == SPA_PROP_channelVolumes) ...

When I wrote this code I didn't know id was the prop id and the API documentation doesn't say anything either. You still have to read source code of pipewire to understand what is going on sadly.

MaxKellermann commented 2 years ago

The crash reported here is not caused by this code in MPD.

saivert commented 2 years ago

It fixed the same type of crash for the pipewire plugin for DeaDBeeF. Crash occurs in the strcmp code because it compares against a NULL. And the control_info event handler is called from the thread spawned by libpipewire. Crash happens at stream.c line 1308 which is pw_stream_emit_control_info macro call which eventually expands into a direct call to the event handler function. Because of lack of debug symbols you don't see the event handler function name in the backtrace.

But we have figured out why pipewire sends NULL strings and it will get fixed upstream so we can just sit tight.