MusicPlayerDaemon / MPD

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

Assertion error (EventLoop::~EventLoop(): Assertion 'timers.empty()' failed) if `state_file` is empty or a non-absolute path #1192

Closed naglis closed 3 years ago

naglis commented 3 years ago

Bug report

Describe the bug

MPD crashes due to an assertion error on startup if state_file configuration option is empty (state_file "") or is not an absolute path (e.g. state_file "foo").

Expected Behavior

MPD logs a warning if the config value is invalid (and ignores it or exits), but does not crash.

Actual Behavior

MPD crashes.

Version

Music Player Daemon 0.22.8 (v0.22.8)
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
 [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 sndio pipe alsa ao openal pulse jack httpd 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 tidal 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:// tidal://

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

Log

config_file: loading file /tmp/mpd_test/mpd.conf
exception: 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.0.31
hybrid_dsd: The Hybrid DSD decoder is disabled because it was not explicitly enabled
exception: Decoder plugin 'wildmidi' is unavailable: configuration file does not exist: /etc/timidity/timidity.cfg
simple_db: reading DB
output: No 'audio_output' defined in config file
output: Attempt to detect audio output device
output: Attempting to detect a sndio audio device
couldn't open play stream: No such file or directory
sndio_output: Error opening default sndio device
output: Attempting to detect a alsa audio device
output: Successfully detected a alsa audio device
exception: Input plugin 'tidal' is not configured: No Tidal application token configured
exception: Input plugin 'qobuz' is not configured: No Qobuz app_id configured
curl: version 7.77.0
curl: with OpenSSL/1.1.1k
avahi: Initializing interface
exception: RTIOThread could not get realtime scheduling, continuing anyway: sched_setscheduler failed: Operation not permitted
avahi: Client changed to state 101
avahi: Client is CONNECTING
mpd: ../../src/event/Loop.cxx:57: EventLoop::~EventLoop(): Assertion `timers.empty()' failed.

Backtrace

#0  0x00007ffff309ad22 in raise () at /usr/lib/libc.so.6
#1  0x00007ffff3084862 in abort () at /usr/lib/libc.so.6
#2  0x00007ffff3084747 in _nl_load_domain.cold () at /usr/lib/libc.so.6
#3  0x00007ffff3093616 in  () at /usr/lib/libc.so.6
#4  0x000055555560e74e in EventLoop::~EventLoop() (this=0x7fffffffd6f8, __in_chrg=<optimized out>) at ../../src/event/Loop.cxx:57
#5  0x00005555555b3730 in EventLoopHolder::~EventLoopHolder() (this=0x7fffffffd6f8, __in_chrg=<optimized out>) at ../../src/Instance.hxx:63
#6  0x00005555555b2be2 in Instance::~Instance() (this=0x7fffffffd6f0, __in_chrg=<optimized out>) at ../../src/Instance.cxx:71
#7  0x000055555558b0ce in MainConfigured(options const&, ConfigData const&) (options=..., raw_config=...) at ../../src/Main.cxx:544
#8  0x000055555558b195 in MainOrThrow(int, char**) (argc=5, argv=0x7fffffffe048) at ../../src/Main.cxx:607
#9  0x000055555558b239 in mpd_main(int, char**) (argc=5, argv=0x7fffffffe048) at ../../src/Main.cxx:615
#10 0x000055555558b2c0 in main(int, char**) (argc=5, argv=0x7fffffffe048) at ../../src/Main.cxx:629

Config

state_file ""
naglis commented 3 years ago

After additional testing, the same assertion error is triggered if state_file_interval or restore_paused are set to an empty or an invalid value (e.g. state_file_interval "", restore_paused "", state_file_interval "-1", restore_paused "?"). Should I create separate issues for these?

MaxKellermann commented 3 years ago

One issue is ok, this is the same bug - when C++ unrolls the stack during failed startup, MPD doesn't properly destruct everything.