MusicPlayerDaemon / MPD

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

Crash when trying to update via WebDAV to a non-WebDAV server #1559

Closed sh1boot closed 2 years ago

sh1boot commented 2 years ago

Bug report

Describe the bug

Setting music_directory to a non-WebDAV server causes mpd to crash at start of update without a coherent complaint about what went wrong.

For example, setting:

music_directory     "http://google.com/"

aborts, with the following backtrace:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x0000fffff48aeea0 in __GI_abort () at abort.c:79
#2  0x0000fffff4ba41a8 in __gnu_cxx::__verbose_terminate_handler() () at /lib/aarch64-linux-gnu/libstdc++.so.6
#3  0x0000fffff4ba1d4c in  () at /lib/aarch64-linux-gnu/libstdc++.so.6
#4  0x0000fffff4ba1db0 in  () at /lib/aarch64-linux-gnu/libstdc++.so.6
#5  0x0000aaaaaab35dc8 in CurlResponseHandlerAdapter::WriteFunction(char*, unsigned long, unsigned long, void*)
    (ptr=0xffffe0004907 "<!DOCTYPE html>\n<html lang=en>\n  <meta charset=utf-8>\n  <meta name=viewport content=\"initial-scale=1, minimum-scale=1, width=device-width\">\n  <title>Error 405 (Method Not Allowed)!!1</title>\n <style>"..., size=1235, nmemb=<optimized out>, stream=0xffffe7ffd9f8) at ../../src/lib/curl/Adapter.cxx:166
#6  0x0000fffff7710e8c in  () at /lib/aarch64-linux-gnu/libcurl-gnutls.so.4
#7  0x0000fffff771fff4 in  () at /lib/aarch64-linux-gnu/libcurl-gnutls.so.4
#8  0x0000fffff7706398 in  () at /lib/aarch64-linux-gnu/libcurl-gnutls.so.4
#9  0x0000fffff7707764 in  () at /lib/aarch64-linux-gnu/libcurl-gnutls.so.4
#10 0x0000fffff77078b4 in curl_multi_socket_action () at /lib/aarch64-linux-gnu/libcurl-gnutls.so.4
#11 0x0000aaaaaab34fe0 in CurlGlobal::SocketAction(int, int) (ev_bitmask=1, fd=<optimized out>, this=<optimized out>)
    at ../../src/lib/curl/Global.cxx:208
#12 CurlSocket::OnSocketReady(unsigned int) (this=<optimized out>, flags=1) at ../../src/lib/curl/Global.cxx:152
#13 0x0000aaaaaab2a73c in EventLoop::Run() (this=0xffffffffdf20) at ../../src/event/Loop.cxx:362
#14 0x0000aaaaaab2b4e8 in BoundMethod<void () noexcept>::operator()() const (this=0xffffffffe7b8) at ../../src/util/BindMethod.hxx:77
#15 Thread::Run() (this=0xffffffffe7b8) at ../../src/thread/Thread.cxx:63
#16 Thread::ThreadProc(void*) (ctx=0xffffffffe7b8) at ../../src/thread/Thread.cxx:92
#17 0x0000fffff4a0b628 in start_thread (arg=0xffffed7aded0) at pthread_create.c:477
#18 0x0000fffff496101c in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78

Expected Behavior

An error message giving the gist of what went wrong (some kind of malformed result, or unexpected return code or whatever).

Actual Behavior

update: starting
terminate called without an active exception
zsh: abort      ./output/debug/mpd --no-daemon --stderr --verbose mpd.conf

Version

Music Player Daemon 0.24 (v0.23.7-211-g60ca12e4b) 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 [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 [sidplay] sid mus str prg P00 [wildmidi] mid [fluidsynth] mid [adplug] amd d00 hsc laa rad raw sa2 [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 sndio pipe alsa ao openal 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:// rtmps:// rtmpt:// rtmpts:// rtp:// rtsp:// rtsps:// scp:// sftp:// smb:// srtp://

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

Configuration

music_directory     "http://google.com/"
playlist_directory  "/tmp/mpddav/playlists"
db_file             "/tmp/mpddav/mpddb"
log_file            "/tmp/mpddav/mpd.log"
state_file          "/tmp/mpddav/mpdstate"
log_level           "verbose"
port                "6601"

Log

curl: version 7.74.0
curl: with GnuTLS/3.7.1
event: RTIOThread could not get realtime scheduling, continuing anyway: sched_setscheduler failed: Operation not permitted
update: spawned thread for update job id 1
state_file: Loading state file /tmp/mpddav/mpdstate
update: starting
terminate called without an active exception
zsh: abort      ./output/debug/mpd --no-daemon --stderr --verbose mpd.conf
sh1boot commented 2 years ago

Moving on to debugging with an rclone webdav instance, the first failure I hit is on the same line, but with the string Unauthorized\n; so there's a more realistic failure case that is also not being handled in the same function.

sh1boot commented 2 years ago

And the actual crash that I was originally having problems with fails in the same point, too. That may be something like a race in rclone (which logs a warning right before it responds in a way that kills mpd), but that'll be easier to debug once I understand how its response upsets mpd.

rclone webdav /a/large/music/folder --addr 127.0.0.1:8080 --read-only --no-modtime --verbose

should be sufficient to create a server if you want to see another potentially-malformed input that crashes mpd.

Interestingly, my debian-built 0.22.6 mpd logs exceptions and then carries on. Like these:

exception: junk after document element
exception: CURL failed: The requested URL returned error: 404 Not Found
exception: CURL failed: The requested URL returned error: 404 Not Found