MusicPlayerDaemon / MPD

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

Satellite mode with NFSv3 server and "version=4" argument results in crash #2040

Closed EdwinKM closed 4 months ago

EdwinKM commented 4 months ago

Bug report

Describe the bug

Recently libnfs URL arguments support is added. commit: https://github.com/MusicPlayerDaemon/MPD/commit/9384bff6f912e2388afa1674f0def66487e776ab feature request: https://github.com/MusicPlayerDaemon/MPD/issues/2039

The basics works (tested all scenarios here: https://github.com/MusicPlayerDaemon/MPD/issues/2039#issuecomment-2101279965). But the combination of a NFSv3 server and "version=4" argument in the config will crash.

Expected Behavior

The combination is still invalid but the application should not crash.

It would be even nicer to validate the NFS server protocols and warn the user about the mismatch:

Should i create a ticket for this? Because this can lead to confusion with users (and thus bug reports: "i see my songs but they will not play")

Actual Behavior

Crash.

Version

edwin@debian:~/MPD/output/release$ ./mpd --version
Music Player Daemon 0.24 (v0.23.15-1321-g9384bff6f)
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

Decoder plugins:
 [mpg123] mp3
 [mad] mp3 mp2
 [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
 [faad] aac
 [mpcdec] mpc
 [wavpack] wv
 [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
 [wildmidi] mid
 [fluidsynth] mid
 [adplug] amd d00 hsc laa rad raw sa2
 [gme] ay gbs gym hes kss nsf nsfe rsn sap spc vgm vgz
 [ffmpeg] 264 265 302 3g2 3gp 4xm 669 722 aa aa3 aac aax ac3 ace acm act adf adp ads adx aea afc aiff aix al alias_pix alp amf amr amrnb amrwb ams anm ans apc ape apl apm apng aptx aptxhd aqt argo_asf argo_brp argo_cvg art asc asf asf_o ass ast au avc avi avif avr avs avs2 avs3 bcstm bethsoftvid bfi bfstm bin bink binka bit bitpacked bmp_pipe bmv boa brender_pix brstm c2 c93 caf cdata cdg cdxl cgi cif cine codec2raw concat cri_pipe dash dat data daud dav dbm dds_pipe dfa dff dfpwm dif digi dirac diz dmf dnxhd dpx_pipe dsf dsicin dsm dss dst dtk dtm dts dtshd dv dvbsub dvbtxt dxa ea eac3 exr_pipe f32be f32le f4v f64be f64le fap far ffmetadata film_cpk fits flac flic flm flv frm fsb fwse g722 g723_1 g726 g726le g729 gdm gdv gem_pipe genh gif gif_pipe gsm gxf h261 h263 h264 h265 h26l hca hcom hevc hls hnm ice ico idcin idf idx iff ifv ilbc image2 image2pipe imf imx ipmovie ipu ircam ism isma ismv iss it iv8 ivf ivr j2b j2k j2k_pipe jacosub jpeg_pipe jpegls_pipe jpegxl_pipe jv kux kvag libgme lmlm4 loas lrc lvf lxf m15 m2a m4a m4b m4v mac mca mcc mdl med mgsts microdvd mj2 mjpeg mjpg mk3d mka mks mkv mlp mlv mm mmcmp mmf mms mo3 mod mods moflex mov mp2 mp3 mp4 mpa mpc mpc8 mpeg mpegts mpegtsraw mpegvideo mpl2 mpo mptm msbc msf msnwctcp msp mt2 mtaf mtm mtv musx mv mvi mxf mxg nfo nist nsp nst nsv nut nuv obu ogg okt oma omg paf pam_pipe pbm_pipe pcx_pipe pfm_pipe pgm_pipe pgmyuv_pipe pgx_pipe phm_pipe photocd_pipe pictor_pipe pjs plm pmp png_pipe pp_bnk ppm ppm_pipe psd_pipe psm psp psxstr pt36 ptm pva pvf qcif qcp qdraw_pipe qoi_pipe r3d rco rcv rgb rl2 rm roq rpl rsd rso rt rtp rtsp s16be s24be s24le s32be s32le s337m s3m sami sap sb sbc sbg scc scd sdp sdr2 sds sdx ser sf sfx sfx2 sga sgi_pipe shn sln smi smk smush sol son sox spdif sph srt ss2 st26 stk stl stm stp str sub sunrast_pipe sup svag svg_pipe svs sw swf tak tco tedcaptions thd thp tiertexseq tiff_pipe tmv tta txd txt ty ty+ u16be u24be u24le u32be u32le ub ul ult umx uw v v210 vag vb vbn_pipe vc1 vidc viv vividas vmd voc vpk vqe vqf vql vt vtt w64 wav wc3movie webm webm_dash_manifest webp_pipe wow wsaud wsd wsvqa wtv wv wve xa xbin xbm_pipe xl xm xmv xpk xpm_pipe xvag xwd_pipe xwma y4m yop yuv yuv10 rtp:// rtsp:// rtsps://
 [pcm]

Filters:
 libsamplerate soxr

Tag plugins:
 id3tag

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

Encoder plugins:
 null vorbis opus lame twolame wave flac shine

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

Input plugins:
 file 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

Configuration

edwin@debian:~/MPD/output/release$ cat /usr/local/etc/mpd.conf |grep -v ^# |grep -v ^$
music_directory     "nfs://san/mnt/tank/music?version=4"
log_file            "~/mpd.log"
log_level           "warning"
auto_update "no"
zeroconf_enabled        "no"
database {
  plugin "proxy"
  host "san"
  port "9999"
}
input {
        plugin "curl"
}
audio_output {
    type        "pulse"
    name        "Pulse Output"
}
filesystem_charset      "UTF-8"

Log

Rebuilt with --buildtype=debug -Db_ndebug=false flags.

edwin@debian:~$ ~/MPD/output/release/mpd  --no-daemon --stdout --verbose
config_file: loading file /usr/local/etc/mpd.conf
server_socket: bind to '0.0.0.0:6600' failed (continuing anyway, because binding to '[::]:6600' succeeded): Failed to bind socket: Address already in use
libsamplerate: libsamplerate converter "Fastest Sinc Interpolator"
vorbis: Xiph.Org libVorbis 1.3.7
opus: libopus 1.3.1
sndfile: libsndfile-1.2.0
decoder: Decoder plugin "wildmidi" is unavailable: configuration file does not exist: /etc/timidity/timidity.cfg
adplug: adplug 2.3.3
input: Input plugin "qobuz" is not configured: No Qobuz app_id configured
curl: version 7.88.1
curl: with GnuTLS/3.7.9
event: RTIOThread could not get realtime scheduling, continuing anyway: sched_setscheduler failed: Operation not permitted
terminate called after throwing an instance of 'fmt::v9::format_error'
  what():  string pointer is null
Aborted
edwin@debian:~$ gdb --args ~/MPD/output/release/mpd --stderr --no-daemon --verbose
GNU gdb (Debian 13.1-3) 13.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/edwin/MPD/output/release/mpd...
(gdb) run
Starting program: /home/edwin/MPD/output/release/mpd --stderr --no-daemon --verbose
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
config_file: loading file /usr/local/etc/mpd.conf
server_socket: bind to '0.0.0.0:6600' failed (continuing anyway, because binding to '[::]:6600' succeeded): Failed to bind socket: Address already in use
libsamplerate: libsamplerate converter "Fastest Sinc Interpolator"
vorbis: Xiph.Org libVorbis 1.3.7
opus: libopus 1.3.1
sndfile: libsndfile-1.2.0
decoder: Decoder plugin "wildmidi" is unavailable: configuration file does not exist: /etc/timidity/timidity.cfg
adplug: adplug 2.3.3
input: Input plugin "qobuz" is not configured: No Qobuz app_id configured
curl: version 7.88.1
curl: with GnuTLS/3.7.9
[New Thread 0x7fffea7ff6c0 (LWP 4505)]
event: RTIOThread could not get realtime scheduling, continuing anyway: sched_setscheduler failed: Operation not permitted
[New Thread 0x7fffe9ffe6c0 (LWP 4506)]
terminate called after throwing an instance of 'fmt::v9::format_error'
  what():  string pointer is null

Thread 2 "rtio" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffea7ff6c0 (LWP 4505)]
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
44  ./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
#1  0x00007ffff44a9e8f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2  0x00007ffff445afb2 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff4445472 in __GI_abort () at ./stdlib/abort.c:79
#4  0x00007ffff469d919 in  () at /lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff46a8e1a in  () at /lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff46a7e89 in  () at /lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007ffff46a85a6 in __gxx_personality_v0 () at /lib/x86_64-linux-gnu/libstdc++.so.6
#8  0x00007ffff4c7c934 in  () at /lib/x86_64-linux-gnu/libgcc_s.so.1
#9  0x00007ffff4c7d38d in _Unwind_Resume () at /lib/x86_64-linux-gnu/libgcc_s.so.1
#10 0x0000555555594149 in fmt::v9::vformat_to_n<char*, , 0>(char*, unsigned long, fmt::v9::basic_string_view<char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<fmt::v9::appender, char> >) (out=<optimized out>, n=<optimized out>, fmt=..., args=...) at /usr/include/fmt/core.h:3253
#11 0x000055555559401a in VFmtToBuffer<256ul>(StringBuffer<256ul>&, fmt::v9::basic_string_view<char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<fmt::v9::appender, char> >)
    (buffer=..., format_str=..., args=...) at ../../src/lib/fmt/ToBuffer.hxx:15
#12 0x0000555555593cbd in VFmtBuffer<256ul>(fmt::v9::basic_string_view<char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<fmt::v9::appender, char> >) (format_str=..., args=...)
    at ../../src/lib/fmt/ToBuffer.hxx:27
#13 0x0000555555593ed9 in FmtBuffer<256ul, char [7], char const*&, char const*&>(char const (&) [7], char const*&, char const*&) (format_str=...) at ../../src/lib/fmt/ToBuffer.hxx:44
#14 0x000055555568538d in FormatNfsClientError(nfs_context*, char const*) (nfs=0x5555559bdf60, msg=0x555555791f01 "nfs_mount_async() failed") at ../../src/lib/nfs/Error.cxx:20
#15 0x00005555556853dc in NfsClientError::NfsClientError(nfs_context*, char const*) (this=0x7fffea7fdd10, nfs=0x5555559bdf60, msg=0x555555791f01 "nfs_mount_async() failed")
    at ../../src/lib/nfs/Error.cxx:24
#16 0x0000555555683ed1 in NfsConnection::MountCallback(int, nfs_context*, void*) (this=0x5555559be000, status=-14, nfs=0x5555559bdf60, data=0x0) at ../../src/lib/nfs/Connection.cxx:544
#17 0x0000555555683232 in NfsConnection::MountCallback(int, nfs_context*, void*, void*) (status=-14, nfs=0x5555559bdf60, data=0x0, private_data=0x5555559be000)
    at ../../src/lib/nfs/Connection.cxx:556
#18 0x00007ffff71d08d2 in  () at /lib/x86_64-linux-gnu/libnfs.so.13
#19 0x00007ffff71d2b1b in  () at /lib/x86_64-linux-gnu/libnfs.so.13
#20 0x00007ffff71c0e36 in  () at /lib/x86_64-linux-gnu/libnfs.so.13
#21 0x00007ffff71d8602 in rpc_process_pdu () at /lib/x86_64-linux-gnu/libnfs.so.13
#22 0x00007ffff71d93c3 in rpc_service () at /lib/x86_64-linux-gnu/libnfs.so.13
#23 0x0000555555683e2a in NfsConnection::Service(unsigned int) (this=0x5555559be000, flags=1) at ../../src/lib/nfs/Connection.cxx:459
#24 0x0000555555682ff5 in NfsConnection::OnSocketReady(unsigned int) (this=0x5555559be000, flags=1) at ../../src/lib/nfs/Connection.cxx:488
#25 0x0000555555684a76 in BindMethodDetail::WrapperGenerator<void (NfsConnection::*)(unsigned int) noexcept, &NfsConnection::OnSocketReady>::Invoke(void*, unsigned int)
    (_instance=0x5555559be000, args#0=1) at ../../src/util/BindMethod.hxx:102
#26 0x000055555563bad2 in BoundMethod<void (unsigned int) noexcept>::operator()(unsigned int) const (this=0x5555559be020, args#0=1) at ../../src/util/BindMethod.hxx:52
#27 0x000055555563bd57 in SocketEvent::Dispatch() (this=0x5555559be008) at ../../src/event/SocketEvent.cxx:105
#28 0x000055555564113f in EventLoop::Run() (this=0x7fffffffccb8) at ../../src/event/Loop.cxx:365
#29 0x00005555556407a9 in EventThread::Run() (this=0x7fffffffccb8) at ../../src/event/Thread.cxx:54
#30 0x00005555555d96fe in BindMethodDetail::WrapperGenerator<void (EventThread::*)() noexcept, &EventThread::Run>::Invoke(void*) (_instance=0x7fffffffccb8) at ../../src/event/Thread.hxx:22
#31 0x000055555563b5e6 in BoundMethod<void () noexcept>::operator()() const (this=0x7fffffffd568) at ../../src/util/BindMethod.hxx:52
#32 0x0000555555644780 in Thread::Run() (this=0x7fffffffd568) at ../../src/thread/Thread.cxx:53
#33 0x0000555555644760 in Thread::ThreadProc(void*) (ctx=0x7fffffffd568) at ../../src/thread/Thread.cxx:82
#34 0x00007ffff44a8134 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#35 0x00007ffff45287dc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
(gdb) quit
A debugging session is active.

    Inferior 1 [process 4502] will be killed.

Quit anyway? (y or n) y