Skip to content

RFC Fix aplay and alsa-lib write_areas() freezing with 100% cpu usage on stuck slave pcm

Sergey alsa-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2pcm: break out of snd_pcm_write_areas() if write function returned 0src/pcm/pcm.c+1 -10 replies
2/2aplay: Escape from pcm_write() when in_aborting stateaplay/aplay.c+1 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC][PATCH 0/2] Fix aplay and alsa-lib write_areas() freezing with 100% cpu usage on stuck slave pcm

These patches originate from aplay -vvv /dev/zero not responding to Ctrl+C when playing to plugged "null", e.g.
  pcm.!default {
    type plug
    slave.pcm { type null }
    slave.format S32_LE
  }

First patch fixes snd_pcm_write_areas() stuck in a loop because of transfer func() always returning 0. That caused application calling it to freeze. In the example above it have frozen aplay. If it was called by firefox, it would freeze firefox.

Is it a good way to fix it? Should snd_pcm_read_areas() be fixed like that too?

Second patch fixes aplay itself, not returning from pcm_write() after SIGINT.

Additionally aplay may restore original interrupt handler, to make second Ctrl+C stop it for sure. In case of other bugs in alsa-lib or third-party slave pcms it seems better than SIGkilling it manually.

Comments and suggestions are welcome.

Regardless of these patches' fate null plugin must be fixed on its own.

Patches (2):
  pcm: break out of snd_pcm_write_areas() if write function returned 0
  aplay: Escape from pcm_write() when in_aborting state

 src/pcm/pcm.c |    2 +-
 aplay/aplay.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 5 lines
1.7.10.4
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel