Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pulseaudio pulseaudio
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 855
    • Issues 855
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 55
    • Merge requests 55
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PulseAudio
  • pulseaudiopulseaudio
  • Issues
  • #164

Closed
Open
Created Jul 09, 2016 by Bugzilla Migration User@bugzilla-migration

tcp transport always fails: PULSE_SERVER=127.0.0.1 src/pacat, Connection failure: Connection terminated

Submitted by Sergei Trofimovich

Assigned to pul..@..op.org

Link to original bug (#96873)

Description

Noticed breakage on real applications like mpv and other media apps.

PA used to work but I'm not sure what exactly changed in my environment.

Currently pulseaudio over TCP is broken on the following versions: 7.1, 8.0, 9.0.

How to reproduce:

  1. run pulseaudio server on one terminal: $ pulseaudio -vvv

  2. run client with PULSE_SERVER=127.0.0.1 set dev/git/pulseaudio $ PULSE_SERVER=127.0.0.1 src/pacat

Analysis:

  1. strace shows there is a failed sendmsg(cmsg_type=SCM_CREDENTIALS) on TCP socket.

    $ PULSE_SERVER=127.0.0.1 strace -f src/pacat

    ppoll([{fd=3, events=POLLIN}, {fd=13, events=POLLIN|POLLOUT}, {fd=0, events=POLLIN}, {fd=5, events=POLLIN}], 4, {29, 999755000}, NULL, 8) = 1 ([{fd=13, revents=POLLOUT}], left {29, 999753448}) write(4, "W", 1) = 1 sendmsg(13, {msg_name(0)=NULL, msg_iov(1)=[{"\0\0\1\24\377\377\377\377\0\0\0\0\0\0\0\0\0\0\0\0", 20}], msg_controllen=32, {cmsg_len=28, cmsg_level=SOL_SOCKET, cmsg_type=SCM_CREDENTIALS{pid=5412, uid=1000, gid=100}}, msg_flags=0}, MSG_NOSIGNAL) = -1 EINVAL (Invalid argument) write(2, "Connection failure: Connection t"..., 42Connection failure: Connection terminated ) = 42 write(4, "W", 1) = 1 write(4, "W", 1) = 1 close(13)

server side sees it as abrupt connection: I: [pulseaudio] socket-server.c: TCP connection accepted by tcpwrap. I: [pulseaudio] client.c: Created 8 "Native client (TCP/IP client from 127.0.0.1:46160)" I: [pulseaudio] client.c: Freed 8 "Native client (TCP/IP client from 127.0.0.1:46160)" I: [pulseaudio] protocol-native.c: Connection died.

Looking at the code there is a few functions that assume UNIX sockets:

pa_iochannel_write_with_creds()
pa_iochannel_write_with_fds()

I've added a few asserts there to explicitly state the invariant of UNIX socket being handled:

diff --git a/src/pulsecore/iochannel.c b/src/pulsecore/iochannel.c
index e62750b..a85de41 100644
--- a/src/pulsecore/iochannel.c
+++ b/src/pulsecore/iochannel.c
@@ -313,2 +313,3 @@ ssize_t pa_iochannel_write_with_creds(pa_iochannel*io, const void*data, size_t l
     pa_assert(io->ofd >= 0);
+    pa_assert(pa_iochannel_creds_supported(io));

@@ -365,2 +366,3 @@ ssize_t pa_iochannel_write_with_fds(pa_iochannel*io, const void*data, size_t l,
     pa_assert(nfd <= MAX_ANCIL_DATA_FDS);
+    pa_assert(pa_iochannel_creds_supported(io));

That allows to get exact backtrace how crash happens:

dev/git/pulseaudio $ PULSE_SERVER=127.0.0.1 src/pacat

Assertion 'pa_iochannel_creds_supported(io)' failed at pulsecore/iochannel.c:314, function     pa_iochannel_write_with_creds(). Aborting.
Aborted (core dumped)

dev/git/pulseaudio $ gdb src/.libs/pacat core.29381

#0  0x00007f814e4591c8 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007f814e4591c8 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007f814e45a61a in __GI_abort () at abort.c:89
#2  0x00007f815164dc5e in pa_iochannel_write_with_creds (io=0xb08830, data=0xb08aa8, l=20, ucred=0xb0a944)
    at pulsecore/iochannel.c:314
#3  0x00007f815166958a in do_write (p=0xb08a60) at pulsecore/pstream.c:777
#4  0x00007f8151666fc1 in do_pstream_read_write (p=0xb08a60) at pulsecore/pstream.c:258
#5  0x00007f8151667358 in io_callback (io=0xb08830, userdata=0xb08a60) at pulsecore/pstream.c:304
#6  0x00007f815164ceff in callback (m=0xb02748, e=0xb08a10, fd=13, f=PA_IO_EVENT_OUTPUT, userdata=0xb08830)
    at pulsecore/iochannel.c:158
#7  0x00007f81518d922a in dispatch_pollfds (m=0xb026f0) at pulse/mainloop.c:655
#8  0x00007f81518da011 in pa_mainloop_dispatch (m=0xb026f0) at pulse/mainloop.c:898
#9  0x00007f81518da18e in pa_mainloop_iterate (m=0xb026f0, block=1, retval=0x7fff98276708) at pulse/mainloop.c:929
#10 0x00007f81518da1ee in pa_mainloop_run (m=0xb026f0, retval=0x7fff98276708) at pulse/mainloop.c:944
#11 0x0000000000406e43 in main (argc=1, argv=0x7fff98276a28) at utils/pacat.c:1202
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking