Gstreamer segfaulting randomly

Today I changed music providers and was surprised to start getting segfaults from my Python program with no error message. Thinking maybe something was wrong with the urls, I tried a nice minimal example and that worked fine. Hm.

My program, a smart home music player, has both a GLib loop and a gRPC loop. After whittling down the Gstreamer code as much as possible I learned nothing beyond the failure being triggered by playbin.set_property('uri', url). Not even setting the environment variable GST_DEBUG=4 would coax it into telling me anything. Finally I moved the call to the very start of the program, prior to even setting up a GLib loop and was pleasantly surprised to see std::runtime_error what(): Unable to read configuration followed by the segfault. What indeed.

Google searches revealed a Debian bug report in some other media player with no fix or workaround, but the report did have lots of speculation that the cause was a library I’ve never heard about named libproxy. Braver souls than I might have looked into why Gstreamer was trying to proxy my requests, but as a lazy bum it seemed easier for me to figure out how to neutralize libproxy by disabling it or creating whatever configuration it wanted. Searching for the string "Unable to read configuration" in that library’s code presented several hits, so it seemed like the bug report’s speculation was correct. In particular, config_sysconfig.cpp and config_envvar.cpp both looked like promising candidates for being the root cause (there’s also a KDE config, but as I don’t use KDE that one seemed unlikely to help.)

Having come across config_sysconfig first, I dutifully put PROXY_ENABLED=no into /etc/sysconfig/proxy, ran my program again, and was immediately greeted with another crash. Fine, maybe config_envvar is what’s running. Initially dismayed to see no PROXY_ENABLED equivalent, the NO_PROXY environment variable used inside get_ignore looked promising but confusing. After further tracing through the code I found that the magic incantation was NO_PROXY=- and now everything works!

What a nuisance.