Bug 89883

Summary: Client freezes intermittently playing over network
Product: PulseAudio Reporter: Tom Hunt <tomdicksonhunt>
Component: daemonAssignee: pulseaudio-bugs
Status: RESOLVED MOVED QA Contact: pulseaudio-bugs
Severity: normal    
Priority: medium CC: bgamari, carl, copycat, flyser42, james, lennart
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Client configuration
Server configuration

Description Tom Hunt 2015-04-03 03:16:46 UTC
Intermittently, when playing over network using module-native-tcp, an error in transmission will occur. It is as yet unknown what exactly triggers this, but it appears in multiple client programs. At this point, the server will log a large number of "Client sent non-aligned memblock" errors, e.g.:

2015-04-01T19:50:39.904968-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 0, length 2841, frame size: 4
2015-04-01T19:50:39.905427-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 2841, length 1255, frame size: 4
2015-04-01T19:50:39.923117-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 0, length 401, frame size: 4
2015-04-01T19:50:39.923327-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 401, length 2896, frame size: 4
2015-04-01T19:50:39.923429-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 3297, length 799, frame size: 4
2015-04-01T19:50:39.923526-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 0, length 629, frame size: 4
2015-04-01T19:50:39.923634-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 629, length 1448, frame size: 4
2015-04-01T19:50:39.924198-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 2077, length 1448, frame size: 4
2015-04-01T19:50:39.924391-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 3525, length 571, frame size: 4
2015-04-01T19:50:39.924488-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 0, length 857, frame size: 4
2015-04-01T19:50:39.924597-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 857, length 1448, frame size: 4
2015-04-01T19:50:39.924692-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 2305, length 1448, frame size: 4
2015-04-01T19:50:39.924954-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 3753, length 343, frame size: 4
2015-04-01T19:50:39.925055-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 0, length 1085, frame size: 4
2015-04-01T19:50:39.925150-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 1085, length 1448, frame size: 4
2015-04-01T19:50:39.925244-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 2533, length 1448, frame size: 4
2015-04-01T19:50:39.925339-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 3981, length 115, frame size: 4
2015-04-01T19:50:39.925435-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 0, length 1313, frame size: 4
2015-04-01T19:50:39.933195-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 1313, length 1448, frame size: 4
2015-04-01T19:50:39.933396-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 2761, length 1335, frame size: 4
2015-04-01T19:50:39.933495-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 0, length 93, frame size: 4
2015-04-01T19:50:39.933712-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 93, length 1448, frame size: 4
2015-04-01T19:50:39.939929-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 1541, length 1448, frame size: 4
2015-04-01T19:50:39.940246-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 2989, length 1107, frame size: 4
2015-04-01T19:50:39.940372-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 0, length 321, frame size: 4
2015-04-01T19:50:39.940498-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 321, length 1448, frame size: 4
2015-04-01T19:50:39.940647-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 1769, length 1371, frame size: 4

The session then becomes unrecoverable, and audio will refuse to play until the client is restarted. It also appears to freeze the client network thread, leading to some degree of unresponsiveness in the client program itself.

The version of PulseAudio in use is 6.0 on both client and server.
Comment 1 Raymond 2015-04-04 06:18:46 UTC
http://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/src/pulsecore/protocol-native.c?id=22827a5e1e627115ae44a297be2ba5b35561700f


: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 0, length 2841, frame size: 4

seem client do not send in wholw frames ,

server don't expect client send  .25, .5 or .75 frame


is this compressed format ?
Comment 2 Tom Hunt 2015-04-04 20:32:15 UTC
Compressed format? What's this?

It is, as far as I can tell, a fairly vanilla pulse install; the only change I've made is to enable TCP audio and set up cookies for that.
Comment 3 Tom Hunt 2015-04-04 21:03:15 UTC
Just for fun, I just compiled a version of pulse 6.0 with the change at that link reversed. The bug indeed disappears at this point.

This is almost certainly not the best way to do it. I would venture that the proper fix is more likely in libpulse somewhere, but I couldn't begin to localize further.
Comment 4 Raymond 2015-04-05 05:51:09 UTC
if you look at http://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/utils/pacat.c

static void do_stream_write(size_t length) {
    size_t l;
    pa_assert(length);

    if (!buffer || !buffer_length)
        return;

    l = length;
    if (l > buffer_length)
        l = buffer_length;

    if (pa_stream_write(stream, (uint8_t*) buffer + buffer_index, l, NULL, 0, PA_SEEK_RELATIVE) < 0) {
        pa_log(_("pa_stream_write() failed: %s"), pa_strerror(pa_context_errno(context)));
        quit(1);
        return;
    }

    buffer_length -= l;
    buffer_index += l;

    if (!buffer_length) {
        pa_xfree(buffer);
        buffer = NULL;
        buffer_index = buffer_length = 0;
    }
}




either length is no multiple of frame size

or

index which is not multiple of frame size 

are invalid when call pa_stream_write()


:

2015-04-01T19:50:39.905427-06:00 localhost pulseaudio[28649]: W: [pulseaudio] protocol-native.c: Client sent non-aligned memblock: index 2841, length 1255, frame size: 4
Comment 5 Tom Hunt 2015-04-05 05:54:39 UTC
If you look there, you see that it seems to get the invalid memblocks in clusters, and the sum of the lengths in each cluster is indeed valid. I would guess the network is doing something strange.
Comment 6 Petr Ivanov 2015-09-15 15:46:59 UTC
Same problem here. 

Configuration: 

Server - Debian sid / Pulseaudio v.6.0-5 from repo / headless, launched via "dbus-launch pulseaudio" from non-root user via ssh / config attached

Client - Calculate (Gentoo) / Pulseaudio v 6.0 from repo (sources) / MATE 1.8.1 / config and USE flags attached

Steps to reproduce:
- Turn on pulseaudio server (dbus-launch pulseaudio in my case)
- Choose remote device in mate-volume-control, "Output" tab.
- Change volume/balance via mate-volume-control

Sometimes bug appeared suddenly, without volume/balance changes, e.g when I watch video using smplayer with sound output to pulseaudio.

Log at server side attached. 

USE flags at client side: 
Installed versions:  6.0(00:14:45 10.09.2015)(X alsa alsa-plugin asyncns bluetooth caps dbus gdbm glib gnome gtk ipv6 native-headset orc ssl tcpd udev webrtc-aec zeroconf -doc -equalizer -jack -libsamplerate -lirc -neon -ofono-headset -oss -qt4 -realtime -selinux -system-wide -systemd -test -xen ABI_MIPS="-n32 -n64 -o32" ABI_PPC="-32 -64" ABI_S390="-32 -64" ABI_X86="32 64 -x32")
Comment 7 Petr Ivanov 2015-09-15 15:47:26 UTC
Created attachment 118287 [details]
Client configuration
Comment 8 Petr Ivanov 2015-09-15 15:47:52 UTC
Created attachment 118288 [details]
Server configuration
Comment 9 iuno 2016-11-01 01:38:54 UTC
I think I am suffering from the same issue, using pulseaudio 9.0.


On the client, I get timeout and "stream killed" (module-tunnel.c), on the server the same message, "non-aligned memblock" (protocol-native.c).

Is there a fix or workaround or some misconfiguration that I might have to look at?
Comment 10 GitLab Migration User 2018-07-30 10:35:29 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/521.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.