halting problem :: Do not link against PulseAudio and JSON-GLib < 0.16

:: ~2 min read

this is a public announcement.

if you link against PulseAudio, whether you want it or not, you’ll get an automatic dependency on json-c, a small C library that parses JSON and doesn’t have any dependency ((which is arguably a plus for a system daemon)). sadly, json-c leaks symbols all over the place, and one of them is called json_object_get_type ((which returns an integer for I don’t know which reason)).

JSON-GLib, the library that yours truly wrote about 6 years ago to parse JSON using a decent C library as a base, also has a type called json_object_get_type ((which returns a GType for the JsonObject boxed structure, so that you can use them in properties and signal marshallers; as it happens, GType is a long lookalike)).

if you link against PulseAudio and JSON-GLib ((or any other library that depends on JSON-GLib, like Clutter)) then you’ll get a segmentation fault with a weird stack trace, like this one and its duplicates ((since both return values and arguments of the functions above are compatible, the linker won’t moan about it, so you won’t see any warning or error when building your code)).

the solution is to use a version of JSON-GLib greater than 0.16.1, which builds JSON-GLib with the -Bsymbolic linker flag ((another solution is to statically link json-c inside PulseAudio instead of dynamically linking it; another solution is to link json-c with -Bsymbolic; yet another solution would be for PA to not use a dependency to parse JSON - or drop JSON entirely because I can’t for the life of me understand why an audio server is dealing with JSON at all)).

that would be all.

context-switch wordpress old-blog