jcorporation / myMPD

myMPD is a standalone and mobile friendly web mpd client with a tiny footprint and advanced features.
https://jcorporation.github.io/myMPD/
GNU General Public License v3.0
418 stars 65 forks source link

munmap_chunk(): invalid pointer #72

Closed CultofRobots closed 5 years ago

CultofRobots commented 5 years ago

Describe the bug

munmap_chunk(): invalid pointer

at moment browser attempts to connect to mympd causing it to fail. I have purged mympd and all configs, reinstalled. Connected via ssl and without to no avail. I have also tried mpd connection with hostname, ip, and socket in mympd.conf. Note that this may be an issue with mpd 0.21.1 itself as 0.21.0 had considerable regressions causing them to push out an upgrade only 2 days later. I haven't had a change to roll it back yet.

OS/software

journalctl dump

Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: Parsing config file: /etc/mympd/mympd.conf
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: Starting myMPD 4.5.0
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: Droping privileges to mympd
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: Document root: "/usr/share/mympd/htdocs"
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: Link to mpd music_directory: "/usr/share/mympd/htdocs/library"
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: Enabling coverimage support
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: Temp dir: "/var/lib/mympd/tmp"
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: Smartpls dir: "/var/lib/mympd/smartpls"
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: State dir: "/var/lib/mympd/state"
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: Reading states
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: Syscmds are disabled
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: Listening on http port 80
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: Listening on ssl port 443
Nov 05 11:21:01 archphile.cultofrobots.net kernel: audit: type=1130 audit(1541434861.136:82): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=mympd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: MPD Connecting to /var/run/mpd/socket:6600
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: MPD connected.
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: MPD protocoll version: 0.21.0
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: MPD supported tags: Artist Album AlbumArtist AlbumArtistSort Title Track Name Genre Date Composer Performer Comment Disc
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: myMPD enabled tags: Artist Album AlbumArtist Title Track Genre Date Composer Performer
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: myMPD enabled searchtags: Artist Album AlbumArtist Title Genre Composer Performer
Nov 05 11:21:01 archphile.cultofrobots.net mympd[20929]: myMPD enabled browsetags: Artist Album AlbumArtist Genre Composer Performer
Nov 05 11:21:14 archphile.cultofrobots.net mympd[20929]: munmap_chunk(): invalid pointer
Nov 05 11:21:14 archphile.cultofrobots.net audit[20929]: ANOM_ABEND auid=4294967295 uid=986 gid=996 ses=4294967295 pid=20929 comm="mympd" exe="/usr/bin/mympd" sig=6 res=1
Nov 05 11:21:14 archphile.cultofrobots.net systemd[1]: mympd.service: Main process exited, code=killed, status=6/ABRT
Nov 05 11:21:14 archphile.cultofrobots.net systemd[1]: mympd.service: Failed with result 'signal'.
Nov 05 11:21:14 archphile.cultofrobots.net audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=mympd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
Nov 05 11:21:14 archphile.cultofrobots.net kernel: audit: type=1701 audit(1541434874.106:83): auid=4294967295 uid=986 gid=996 ses=4294967295 pid=20929 comm="mympd" exe="/usr/bin/mympd" sig=6 res=1
Nov 05 11:21:14 archphile.cultofrobots.net kernel: audit: type=1131 audit(1541434874.116:84): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=mympd comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
jcorporation commented 5 years ago

hm, after getting the enabled tags, myMPD updates the smart playlists. I don't see this in your output.

Can you set the log_level "verbose" in mpd.conf and give me the mpd.log after restarting mpd and myMPD.

What libmpdclient version is installed?

CultofRobots commented 5 years ago

libmpdclient 2.16-1

Smart playlists are disabled along with stickers, syscmds, and local player for the moment. Here's my config

mpdhost = /var/run/mpd/socket
mpdport = 6600
mpdpass = <REDACTED>

#Webserver options
webport = 80

#Enable ssl
ssl = true
sslport = 443
sslcert = /etc/mympd/ssl/server.pem
sslkey = /etc/mympd/ssl/server.key

#myMPD user
user = mympd

#Enable local player, needs streamport or streamurl setting
localplayer = false

#Port for mpd http stream
streamport = 8002

#Manual streamurl, overwrites streamport
#streamurl = http://jukebox:8000

#Enable coverimages
coverimage = true

#Name for coverimages
coverimagename = folder.jpg

#myMPD state directory
varlibdir = /var/lib/mympd

#Enable mixramp settings
mixramp = false

#Enable usage of mpd stickers for play statistics and voting
stickers = false

#List of tags in myMPD gui
taglist = Artist,Album,AlbumArtist,Title,Track,Genre,Date,Composer,Performer
searchtaglist = Artist,Album,AlbumArtist,Title,Genre,Composer,Performer
browsetaglist = Artist,Album,AlbumArtist,Genre,Composer,Performer

#Enable smart playlists
smartpls = false

#Enable system commands in /etc/mympd/syscmds/
syscmds = false

#Elements per page for pagination, max: 400
max_elements_per_page = 100
CultofRobots commented 5 years ago

Here's the mpd verbose log with me starting mympd with socket, localhost, machine ip and hostname:

Nov 05 13:06 : state_file: Loading state file /var/lib/mpd/mpdstate
Nov 05 13:06 : client: [0] opened from local
Nov 05 13:06 : client: [0] process command "subscribe "mpdscribble""
Nov 05 13:06 : client: [0] command returned 0
Nov 05 13:06 : client: [0] process command list
Nov 05 13:06 : client: process command "status"
Nov 05 13:06 : client: command returned 0
Nov 05 13:06 : client: process command "currentsong"
Nov 05 13:06 : client: command returned 0
Nov 05 13:06 : client: [0] process command list returned 0
Nov 05 13:06 : client: [0] process command "idle player message"
Nov 05 13:06 : client: [0] command returned 1
Nov 05 13:06 : client: [1] opened from local
Nov 05 13:06 : client: [1] process command "password "<REDACTED>""
Nov 05 13:06 : client: [1] command returned 0
Nov 05 13:06 : client: [1] process command "commands"
Nov 05 13:06 : client: [1] command returned 0
Nov 05 13:06 : client: [1] process command "tagtypes"
Nov 05 13:06 : client: [1] command returned 0
Nov 05 13:06 : client: [1] process command "idle"
Nov 05 13:06 : client: [1] command returned 1
Nov 05 13:06 : client: [1] process command "idle"
Nov 05 13:06 : client: [1] command returned 1
Nov 05 13:06 : client: [1] process command "currentsong"
Nov 05 13:06 : client: [1] command returned 0
Nov 05 13:06 : client: [1] closed
Nov 05 13:07 : client: [2] opened from ::ffff:127.0.0.1:51574
Nov 05 13:07 : client: [2] process command "password "<REDACTED>""
Nov 05 13:07 : client: [2] command returned 0
Nov 05 13:07 : client: [2] process command "commands"
Nov 05 13:07 : client: [2] command returned 0
Nov 05 13:07 : client: [2] process command "tagtypes"
Nov 05 13:07 : client: [2] command returned 0
Nov 05 13:07 : client: [2] process command "idle"
Nov 05 13:07 : client: [2] command returned 1
Nov 05 13:07 : client: [2] process command "idle"
Nov 05 13:07 : client: [2] command returned 1
Nov 05 13:07 : client: [2] process command "idle"
Nov 05 13:07 : client: [2] command returned 1
Nov 05 13:07 : client: [2] process command "currentsong"
Nov 05 13:07 : client: [2] command returned 0
Nov 05 13:07 : client: [2] closed
Nov 05 13:08 : client: [3] opened from ::ffff:127.0.0.1:49202
Nov 05 13:08 : client: [3] process command "password "<REDACTED>""
Nov 05 13:08 : client: [3] command returned 0
Nov 05 13:08 : client: [3] process command "commands"
Nov 05 13:08 : client: [3] command returned 0
Nov 05 13:08 : client: [3] process command "tagtypes"
Nov 05 13:08 : client: [3] command returned 0
Nov 05 13:08 : client: [3] process command "idle"
Nov 05 13:08 : client: [3] command returned 1
Nov 05 13:08 : client: [3] process command "idle"
Nov 05 13:08 : client: [3] command returned 1
Nov 05 13:08 : client: [3] process command "idle"
Nov 05 13:08 : client: [3] command returned 1
Nov 05 13:08 : client: [3] process command "currentsong"
Nov 05 13:08 : client: [3] command returned 0
Nov 05 13:08 : client: [3] closed
Nov 05 13:08 : client: [4] opened from ::ffff:127.0.0.1:49204
Nov 05 13:08 : client: [4] process command "password "<REDACTED>""
Nov 05 13:08 : client: [4] command returned 0
Nov 05 13:08 : client: [4] process command "commands"
Nov 05 13:08 : client: [4] command returned 0
Nov 05 13:08 : client: [4] process command "tagtypes"
Nov 05 13:08 : client: [4] command returned 0
Nov 05 13:08 : client: [4] process command "idle"
Nov 05 13:08 : client: [4] command returned 1
Nov 05 13:08 : client: [4] process command "idle"
Nov 05 13:08 : client: [4] command returned 1
Nov 05 13:08 : client: [4] process command "currentsong"
Nov 05 13:08 : client: [4] command returned 0
Nov 05 13:08 : client: [4] closed
Nov 05 13:09 : client: [5] opened from ::ffff:192.168.1.20:34860
Nov 05 13:09 : client: [5] process command "password "<REDACTED>""
Nov 05 13:09 : client: [5] command returned 0
Nov 05 13:09 : client: [5] process command "commands"
Nov 05 13:09 : client: [5] command returned 0
Nov 05 13:09 : client: [5] process command "tagtypes"
Nov 05 13:09 : client: [5] command returned 0
Nov 05 13:09 : client: [5] process command "idle"
Nov 05 13:09 : client: [5] command returned 1
Nov 05 13:09 : client: [5] process command "idle"
Nov 05 13:09 : client: [5] command returned 1
Nov 05 13:09 : client: [5] process command "currentsong"
Nov 05 13:09 : client: [5] command returned 0
Nov 05 13:09 : client: [5] closed
Nov 05 13:09 : client: [6] opened from ::ffff:127.0.0.1:49208
Nov 05 13:09 : client: [6] process command "password "<REDACTED>""
Nov 05 13:09 : client: [6] command returned 0
Nov 05 13:09 : client: [6] process command "commands"
Nov 05 13:09 : client: [6] command returned 0
Nov 05 13:09 : client: [6] process command "tagtypes"
Nov 05 13:09 : client: [6] command returned 0
Nov 05 13:09 : client: [6] process command "idle"
Nov 05 13:09 : client: [6] command returned 1
Nov 05 13:09 : client: [6] process command "idle"
Nov 05 13:09 : client: [6] command returned 1
Nov 05 13:09 : client: [6] process command "idle"
Nov 05 13:09 : client: [6] command returned 1
Nov 05 13:09 : client: [6] process command "currentsong"
Nov 05 13:09 : client: [6] command returned 0
Nov 05 13:09 : client: [6] closed
Nov 05 13:09 : state_file: Saving state file /var/lib/mpd/mpdstate
Nov 05 13:09 : fifo_output: Removing FIFO "/tmp/mpd.fifo"
jcorporation commented 5 years ago

The config seems god, but it is unusual that the connection closes after the "currentsong" command. Can you connect with telnet and emit "currentsong" command manually:

# telnet localhost 6600
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
OK MPD 0.20.0
currentsong
file: Alben/Covenant-Skyshaper/01.Ritual_Noise.mp3
Last-Modified: 2018-07-19T19:00:24Z
Artist: Covenant
AlbumArtist: Covenant
Title: Ritual Noise
Album: Skyshaper
Track: 1
Genre: Alternative
Time: 438
duration: 438.413
Pos: 0
Id: 20
OK

If this works: Can you compile myMPD with ./mkdebug and start it manually in the debug directory. With mkdebug myMPD is compiled with static libasan, that should narrow down the memory error.

CultofRobots commented 5 years ago

but it is unusual that the connection closes after the "currentsong" command.

There's the problem. The current song was https://api.soundcloud.com/tracks/470634147/stream?client_id=a25e51780f7f86af0afa91f241d091f8

When playing a regular flac file everything works fine.

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
OK MPD 0.21.0
currentsong
file: downloads/add_replaygain/Nurse With Wound - (2018) Sinister Whimsy to the Wretched/Disc II - Large Ladies With Cake in the Oven/201 - Bearded Lady.flac
Last-Modified: 2018-11-03T22:46:28Z
Artist: Nurse With Wound
Album: Sinister Whimsy to the Wretched
AlbumArtist: Nurse With Wound
Title: Bearded Lady
Track: 01
Genre: Experimental
Date: 2018
Disc: 2
Time: 144
duration: 144.000
Pos: 7
Id: 30
OK

But when I load something from soundcloud mympd immediately crashes. Telnet output for a soundcloud track:

Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
OK MPD 0.21.0
currentsong
file: https://api.soundcloud.com/tracks/478592133/stream?client_id=a25e51780f7f86af0afa91f241d091f8
Name: EHE 19.07.18 - Novo Line - Qatsi and Die in LA
Time: 1876
duration: 1876.290
Pos: 20
Id: 3
OK

mympd also crashed immediately on other streams such as the following: http://79.111.119.111:9109/ (aac stream) https://wwfm.streamguys1.com/live-mp3 (mp3 stream) http://audio-ogg.ibiblio.org:8000/wcpe.ogg (ogg stream)

Without looking at the code my first guess would be empty tags are not accounted for.

EDIT: I should note, all these streams worked fine on the previous build.

jcorporation commented 5 years ago

That was also my first guess, but it was the way myMPD calculates the coverimage. Fix is in master and I publish a new release with that fix.

CultofRobots commented 5 years ago

Nice work. I'll build and install it later in the the evening. Thanks.