Bug#944509: libportaudio2: random crashes in pa_linux_alsa.c: Assertion failed - fix available

Norbert Preining norbert at preining.info
Mon Nov 11 03:49:46 GMT 2019


Package: libportaudio2
Version: 19.6.0-1
Severity: important

Dear PA maintainers,

our RaspberryPi based smart speaker software started crashing with the
update to buster - the reason is not really clear, but pyaudio started
to crash with
	python3: src/hostapi/alsa/pa_linux_alsa.c:3641: PaAlsaStreamComponent_BeginPolling: Assertion `ret == self->nfds' failed.
I could reproduce this bug 100% with our pyaudio based application on
arm, but I guess it might show up in other areas, too.

Fortunately, there is a patch posted to the portaudio mailing list
already back in July 2019 (but I only found it recently).

	https://lists.columbia.edu/pipermail/portaudio/2019-July/001888.html

I rebuild the arm version of libportaudio2 locally and after installing
it on our system, with nothing else changed, the crashed went away.
(patch attached)

I have already contacted upstream mailing list to include the patch, but
the activity level of development there is rather low.

Could you be so nice and include this patch into the Debian sources,
ideally backporting/uploading it also to buster?

Thanks a lot and all the best

Norbert



-- System Information:
Debian Release: bullseye/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (200, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.3.10 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_WARN, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages libportaudio2 depends on:
ii  libasound2                1.1.9-1
ii  libc6                     2.29-3
ii  libjack0 [libjack-0.125]  1:0.125.0-3+b1

libportaudio2 recommends no packages.

libportaudio2 suggests no packages.

-- no debconf information
-------------- next part --------------
diff --git a/src/hostapi/alsa/pa_linux_alsa.c b/src/hostapi/alsa/pa_linux_alsa.c
index 584cde8..643198c 100644
--- a/src/hostapi/alsa/pa_linux_alsa.c
+++ b/src/hostapi/alsa/pa_linux_alsa.c
@@ -3628,12 +3628,18 @@ error:
 
 /** Fill in pollfd objects.
  */
-static PaError PaAlsaStreamComponent_BeginPolling( PaAlsaStreamComponent* self, struct pollfd* pfds )
+static PaError PaAlsaStreamComponent_BeginPolling( PaAlsaStreamComponent* self, struct pollfd* pfds, int *xrunOccurred )
 {
     PaError result = paNoError;
     int ret = alsa_snd_pcm_poll_descriptors( self->pcm, pfds, self->nfds );
-    (void)ret;  /* Prevent unused variable warning if asserts are turned off */
-    assert( ret == self->nfds );
+    if( -EPIPE == ret )
+    {
+      *xrunOccurred = 1;
+    }
+    else
+    {
+      assert( ret == self->nfds );
+    }
 
     self->ready = 0;
 
@@ -3794,17 +3800,22 @@ static PaError PaAlsaStream_WaitForFrames( PaAlsaStream *self, unsigned long *fr
         if( pollCapture )
         {
             capturePfds = self->pfds;
-            PA_ENSURE( PaAlsaStreamComponent_BeginPolling( &self->capture, capturePfds ) );
+            PA_ENSURE( PaAlsaStreamComponent_BeginPolling( &self->capture, capturePfds, &xrun ) );
             totalFds += self->capture.nfds;
         }
         if( pollPlayback )
         {
             /* self->pfds is in effect an array of fds; if necessary, index past the capture fds */
             playbackPfds = self->pfds + (pollCapture ? self->capture.nfds : 0);
-            PA_ENSURE( PaAlsaStreamComponent_BeginPolling( &self->playback, playbackPfds ) );
+            PA_ENSURE( PaAlsaStreamComponent_BeginPolling( &self->playback, playbackPfds, &xrun ) );
             totalFds += self->playback.nfds;
         }
 
+        if ( xrun )
+        {
+          break;
+        }
+
 #ifdef PTHREAD_CANCELED
         if( self->callbackMode )
         {


More information about the Pkg-voip-maintainers mailing list