Sometimes you get to write code that just doesn’t make any sense at all. Like this:
// BLACK MAGIC: persuade mono not to crash var x = Bass.BASS_GetVersion().ToString();
Of course, the variable x will neither be used nor touched anywhere else in code and the whole thing seems rather questionable. But:
Removing it, or placing it elsewhere in the code will reliably make the application crash with an obscure segfault in mono 3.2.3 on ARM Linux – The jargon file’s Story About Magic comes to mind.
Also, presumably the crash happens due to unspecified native library load order differences between .NET and mono – This certainly appears to be the case, from what we gathered by investigating with gdb. But why? I don’t know, and the folks at #firstname.lastname@example.org appear not to, either.
Oh well. “We don’t know why we have to do this, but it works.” – All hail the art of Black Magic computer programming! My thanks go to the great master of sorcery, Ian Luck of un4seen.com fame, and to Shana and ShawnWhite from #email@example.com for helping me devise this great spell of protection, which essentially ensures that libbass.so is loaded when we access libbassmix.so – even under mono.