2017-03-28 06:21 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0004662MPDpublic2017-03-22 20:37
Reportermisc 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusnewResolutionopen 
Platformx64OSLinuxOS Version
Product Versiongit 
Target VersionFixed in Version 
Summary0004662: Livelock when switching between files played to different bit depths
DescriptionCurrently mpd runs into a livelock eg. when manually switching from a playing mp3 to a flac file.

audio_output {
 type "alsa"
 name "HDA Intel"
 format "44100:*:2"
}

shows the issue, whereas it does not happen when format is changed to "44100:16:2".

This occurs with mpd-git. mpd 0.20.5 (both compiled to the same deps) does not exhibit the issue.
TagsNo tags attached.
Attached Files

-Relationships
+Relationships

-Notes

~0010416

cirrus (administrator)

What are the symptoms? How do you know it's a livelock?

~0010417

misc (reporter)

Process jumps to 100% CPU, is unresponsive and won't respond to SIGTERM.

~0010418

cirrus (administrator)

How do you know it's a livelock and not an endless loop?

~0010419

misc (reporter)

I don't, it's a guess due to your recent improvements involving a lot of threading.

~0010422

cirrus (administrator)

No matter how hard I try with your configuration, MPD just works.

Which MPD thread(s) consume so much CPU? Upload a strace of that thread.

~0010429

misc (reporter)

Bisected to b1c7649 "output/alsa: non-blocking mode", I'll see when I can get the strace.

~0010432

cirrus (administrator)

It's not a livelock. Your random guess was wrong and misleading.

~0010434

cirrus (administrator)

This looks very much like an ALSA bug:

http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/pcm/pcm/pcm_dmix.c;h=46142e5d2e2496cb2ceb6ee6613e7f8ae23c2233;hb=HEAD#l642

When dmix is used, snd_pcm_drain() *always* and unconditionally returns EAGAIN without checking anything, if the ALSA device was opened in non-blocking mode. There is never any progress.

EAGAIN is the code for "wait until the file descriptors I gave you become ready and ask me again". This is exactly what MPD does - and the one ALSA file descriptor is always ready, leading to an endless busy loop.

~0010436

skidoo (reporter)

Is snd_pcm_poll_descriptors_revents neccessary for pcm plugins?

https://github.com/Arkq/bluez-alsa/issues/35

http://alsa-devel.alsa-project.narkive.com/KQnCNEXO/asterisk-1-4-17-and-alsa-1-0-19-dmix-plugin-problem

~0010437

cirrus (administrator)

I don't know. Do you have any usable documentation for that function? I don't understand its official documentation.

~0010444

cirrus (administrator)

Confirmed ALSA bug: http://mailman.alsa-project.org/pipermail/alsa-devel/2017-March/118879.html

~0010445

misc (reporter)

Yup, installed alsa-lib from git and mpd is back running fine.

Sorry for the misdirection.
+Notes

-Issue History
Date Modified Username Field Change
2017-03-06 01:38 misc New Issue
2017-03-08 17:31 cirrus Note Added: 0010416
2017-03-08 17:37 misc Note Added: 0010417
2017-03-08 17:39 cirrus Note Added: 0010418
2017-03-08 17:47 misc Note Added: 0010419
2017-03-10 14:14 cirrus Note Added: 0010422
2017-03-13 22:44 misc Note Added: 0010429
2017-03-13 23:26 misc File Added: strace.tar.xz
2017-03-13 23:26 misc File Added: strace.tar-2.xz
2017-03-15 16:24 cirrus Note Added: 0010432
2017-03-16 13:18 cirrus Note Added: 0010434
2017-03-17 23:03 skidoo Note Added: 0010436
2017-03-17 23:10 cirrus Note Added: 0010437
2017-03-21 08:58 cirrus Note Added: 0010444
2017-03-22 20:37 misc Note Added: 0010445
+Issue History