Race condition in AlsaClient (juce_linux_Midi.cpp)


The destructor of AlsaClient is first closing the snd_seq handle, and then it stops the ‘MidiInputThread’ instance. It must be done the other way around, otherwise the thread will poll a destroyed handle, and will randomly crash the application with something like
snd_seq_poll_descriptors_count: Assertion seq->streams & SND_SEQ_OPEN_INPUT’ failed.`

Easy to reproduce by calling start() of a new MidiInput instance and then immediately destroying it.

Yeah that looks pretty suspect. Thanks for reporting, we’ll push a fix for this shortly.