ALSA issues inside the sandbox

Hello,
I’ve been working on improving audio support in my Flatpak of Purr Data, and noticing some strange issues which I can’t explain.

Trying open an ALSA device sometimes results in dlopen() errors like this:

ALSA lib ../../src/dlmisc.c:170:(snd_dlsym_verify) unable to verify version for symbol _snd_pcm_plug_open
ALSA lib ../../src/dlmisc.c:295:(snd1_dlobj_cache_get) symbol _snd_pcm_plug_open is not defined inside [builtin]
snd_pcm_open (input): No such device or address
ALSA lib ../../src/dlmisc.c:170:(snd_dlsym_verify) unable to verify version for symbol _snd_pcm_plug_open
ALSA lib ../../src/dlmisc.c:295:(snd1_dlobj_cache_get) symbol _snd_pcm_plug_open is not defined inside [builtin]
snd_pcm_open (output): No such device or address

This seems like a runtime issue, except that the ALSA libraries are all present in /usr/lib/x86_64-linux-gnu/alsa-lib/ as far as I can see … and they do sometimes work, so it’s not completely reproducible

Has anyone seen a problem like this before, or have any tips for debugging it?