pw_get_prgname is not thread safe
Version, Distribution, Desktop Environment:
pipewire 0.3.30 in yocto
Description of Problem:
snd_pcm_pipewire_open() segfaults and it seems to be because two threads are calling pw_get_prgname() simultaneously:
Program terminated with signal SIGSEGV, Segmentation fault. #0 strlen () at ../sysdeps/arm/armv6t2/strlen.S:126 [Current thread is 1 (LWP 1357)] #0 strlen () at ../sysdeps/arm/armv6t2/strlen.S:126 #1 0x76a56e2c in __vfprintf_internal (s=s@entry=0x7e898448, format=format@entry=0x748de6bc "PipeWire ALSA [%s]", ap=..., ap@entry=..., mode_flags=mode_flags@entry=2) at vfprintf-internal.c:1647 #2 (closed) 0x76a61b50 in __vasprintf_internal (result_ptr=result_ptr@entry=0x7e898510, format=0x748de6bc "PipeWire ALSA [%s]", args=..., mode_flags=2) at vasprintf.c:57 #3 0x76ab6cfc in __vasprintf_chk (result_ptr=result_ptr@entry=0x7e898510, flag=flag@entry=1, format=, ap=...) at vasprintf_chk.c:36 #4 (closed) 0x74890442 in vasprintf (__ap=..., __fmt=, __ptr=0x7e898510) at /usr/include/bits/stdio2.h:218 #5 (closed) pw_properties_setva (properties=0xca9770, key=0x748de534 "application.name", format=, args=...) at ../git/src/pipewire/properties.c:470 #6 (closed) 0x748904ae in pw_properties_setf (properties=properties@entry=0xca9770, key=, format=0x748de6bc "PipeWire ALSA [%s]") at ../git/src/pipewire/properties.c:498 #7 0x748dd7fa in snd_pcm_pipewire_open (period_bytes=1280, channels=1, format=SND_PCM_FORMAT_S32_LE, rate=16000, flags=0, mode=1, stream=SND_PCM_STREAM_PLAYBACK, capture_node=, playback_node=, server_name=0x0, node_name=, name=0xcc7028 "audiosink0", pcmp=0x7e898818) at ../git/pipewire-alsa/alsa-plugins/pcm_pipewire.c:1031 #8 (closed) _snd_pcm_pipewire_open (pcmp=0x7e898818, name=0xcc7028 "audiosink0", root=, conf=, stream=SND_PCM_STREAM_PLAYBACK, mode=1) at ../git/pipewire-alsa/alsa-plugins/pcm_pipewire.c:1177
How Reproducible:
It's racy...