Snap and shared memory reading/writing

Almost two years after jack1 (JACK audio connection kit) support landed in snapd, I’m now trying to enable jack2 support.

As with jack1, jack2 clients connect to the jack2 server via a shared memory segment.
I have created the necessary interface, and built a example snap client.

The client can connect to the server, however, they fail to properly communicate, for reasons I don’t understand.

I have put the snap in devmode, but I don’t see any violation with journalctl.

$ sudo sysctl -w kernel.printk_ratelimit=0 ; journalctl --follow | grep audit
kernel.printk_ratelimit = 0
fév 16 22:39:02 voyager audit[254564]: AVC apparmor="ALLOWED" operation="open" profile="snap.jack-client-test.jack-client-test" name="/snap/core/10823/usr/share/locale/fr/LC_MESSAGES/snappy.mo" pid=254564 comm="snap-exec" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
fév 16 22:39:02 voyager kernel: audit: type=1400 audit(1613511542.788:649): apparmor="ALLOWED" operation="open" profile="snap.jack-client-test.jack-client-test" name="/snap/core/10823/usr/share/locale/fr/LC_MESSAGES/snappy.mo" pid=254564 comm="snap-exec" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0

I can see the error when I run the snap with strace :

$ snap run --strace jack-client-test
...
[pid 249282] set_robust_list(0x7fa69ebe49e0, 24) = 0
[pid 249282] futex(0x564d73ae9c58, FUTEX_WAIT_PRIVATE, 0, NULL <unfinished ...>
[pid 249255] rt_sigprocmask(SIG_BLOCK, [PIPE], [], 8) = 0
[pid 249255] socket(AF_UNIX, SOCK_STREAM, 0) = 3
[pid 249255] getuid()                   = 1000
[pid 249255] connect(3, {sa_family=AF_UNIX, sun_path="/dev/shm/jack_default_1000_0"}, 110) = 0
[pid 249255] shutdown(3, SHUT_RDWR)     = 0
[pid 249255] close(3)                   = 0
[pid 249255] socket(AF_UNIX, SOCK_STREAM, 0) = 3
[pid 249255] getuid()                   = 1000
[pid 249255] connect(3, {sa_family=AF_UNIX, sun_path="/dev/shm/jack_default_1000_0"}, 110) = 0
[pid 249255] write(3, "\26\0\0\0", 4)   = 4
[pid 249255] write(3, "Q\0\0\0", 4)     = 4
[pid 249255] write(3, "jack-client-test\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 65) = 65
[pid 249255] write(3, "\10\0\0\0", 4)   = 4
[pid 249255] write(3, "\1\0\0\0", 4)    = -1 EPIPE (Broken pipe)
[pid 249255] write(2, "Cannot write socket fd = 3 err ="..., 45) = 45

The client is pretty simple (it’s the same client I used when I did jack1), and it works perfectly outside the snap, or with the snap in classic confinement.

I’m a bit lost now, and I don’t really know where to look to make this work. I didn’t have this problem with jack1.

Has anyone encountered a similar situation ? What kind of data should I provide here to help you guys diagnose my problem ?

Thanks !