On Wed, Jun 29, 2016 at 06:02:58PM +0200, Takashi Iwai wrote:
Now I reread the code again, and I guess it's really the racy accesses. Basically you can't call alsa-lib functions concurrently. For example, calling snd_pcm_avail_update() from multiple threads concurrently may lead to such an error. Internally it copies / converts the content (e.g. for softvol plugin), and this would conflict when called in parallel.
You can try a hackish patch below to see whether it emits any messages. It has no mutex, so the code itself is racy, but it should be enough just as a check.
Meanwhile, the crash itself might be avoided by disabling "pcm->mmap_shadow = 1" line in pcm_softvol.c. Then it'll be copied to the external buffer.
Thank you Takashi, I will give it a try!
Baptiste
diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c index 8527783c3569..571defad6e12 100644 --- a/src/pcm/pcm_plugin.c +++ b/src/pcm/pcm_plugin.c @@ -483,17 +483,25 @@ snd_pcm_plugin_mmap_commit(snd_pcm_t *pcm,
static snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm) {
static snd_pcm_t *check = NULL; snd_pcm_plugin_t *plugin = pcm->private_data; snd_pcm_t *slave = plugin->gen.slave; snd_pcm_sframes_t slave_size; int err;
if (!check)
check = pcm;
else if (pcm == check)
fprintf(stderr, "XXX RACY CALL\n");
slave_size = snd_pcm_avail_update(slave); if (pcm->stream == SND_PCM_STREAM_CAPTURE && pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED && pcm->access != SND_PCM_ACCESS_RW_NONINTERLEAVED) goto _capture; *pcm->hw.ptr = *slave->hw.ptr;
if (pcm == check)
check = NULL; return slave_size;
_capture: {
@@ -545,11 +553,15 @@ static snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm) slave_size -= slave_frames; xfer += frames; }
if (pcm == check)
check = NULL;
return (snd_pcm_sframes_t)xfer;
error_atomic: snd_atomic_write_end(&plugin->watom); error:
if (pcm == check)
check = NULL;
return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; }
}