Crash on MIDI input, appears after 'Added support for ID-based MIDI devices' commit (09ebd1d257614571c47af0d08a5f90ba01a7f5c0)

I was just testing the midi input portion of my app, and it is crashing in AudioDeviceManager::handleIncomingMidiMessageInt. It seems that the MidiInput* source is bad and points to a bunch of garbage. I’m using the AudioDeviceManager to open the input

void MidiInputMapping::configureMidiInputDevice()
{
    const auto deviceName = midiConfig.getDeviceName();
    auto midiInputs = MidiInput::getDevices();
    for (auto midiInput : midiInputs)
    {
        if (midiInput == deviceName)
        {
            Logger::outputDebugString ("Using [" + deviceName + "] Midi Device");
            audioDeviceManager->setMidiInputEnabled (midiInput, true);
            audioDeviceManager->addMidiInputCallback (midiInput, this);
        }
        else
        {
            audioDeviceManager->setMidiInputEnabled (midiInput, false);
            audioDeviceManager->removeMidiInputCallback (midiInput, this);
        }
    }
}

Contents of MidiInput* source

|-||source|0x0000005f38efe660 {deviceInfo={name={text={data=0x00000000000000b8 <Error reading characters of string.> } } ...} ...}|juce::MidiInput *|
|---|---|---|---|---|
|-||deviceInfo|{name={text={data=0x00000000000000b8 <Error reading characters of string.> } } identifier={text={data=...} } }|juce::MidiDeviceInfo|
|-||name|{text={data=0x00000000000000b8 <Error reading characters of string.> } }|juce::String|
|-||text|{data=0x00000000000000b8 <Error reading characters of string.> }|juce::CharPointer_UTF8|
|+||data|0x00000000000000b8 <Error reading characters of string.>|char *|
|-||identifier|{text={data=0x0000005f00000000 <Error reading characters of string.> } }|juce::String|
|-||text|{data=0x0000005f00000000 <Error reading characters of string.> }|juce::CharPointer_UTF8|
|+||data|0x0000005f00000000 <Error reading characters of string.>|char *|

Callstack

 	Live Controller.exe!std::_Fetch_add_seq_cst_4(volatile unsigned long * _Tgt, unsigned long _Value) Line 1543	C++
 	Live Controller.exe!std::_Atomic_fetch_add_4(volatile unsigned long * _Tgt, unsigned long _Value, std::memory_order _Order) Line 1585	C++
 	Live Controller.exe!std::atomic_fetch_add_explicit(std::_Atomic_int * _Atom, int _Value, std::memory_order _Order) Line 910	C++
 	Live Controller.exe!std::atomic_fetch_add(std::_Atomic_int * _Atom, int _Value) Line 921	C++
 	Live Controller.exe!std::_Atomic_int::operator++() Line 1035	C++
 	Live Controller.exe!juce::Atomic<int>::operator++() Line 122	C++
 	Live Controller.exe!juce::StringHolder::retain(const juce::CharPointer_UTF8 text) Line 161	C++
 	Live Controller.exe!juce::String::String(const juce::String & other) Line 253	C++
 	Live Controller.exe!juce::MidiInput::getName() Line 149	C++
>	Live Controller.exe!juce::AudioDeviceManager::handleIncomingMidiMessageInt(juce::MidiInput * source, const juce::MidiMessage & message) Line 893	C++
 	Live Controller.exe!juce::AudioDeviceManager::CallbackHandler::handleIncomingMidiMessage(juce::MidiInput * source, const juce::MidiMessage & message) Line 75	C++
 	Live Controller.exe!juce::MidiDataConcatenator::pushMidiData<juce::MidiInput,juce::MidiInputCallback>(const void * inputData, int numBytes, double time, juce::MidiInput * input, juce::MidiInputCallback & callback) Line 96	C++
 	Live Controller.exe!juce::Win32MidiService::Win32InputWrapper::pushMidiData(const void * inputData, int numBytes, double time) Line 467	C++
 	Live Controller.exe!juce::Win32MidiService::MidiInCollector::handleMessage(const unsigned char * bytes, unsigned int timeStamp) Line 149	C++
 	Live Controller.exe!juce::Win32MidiService::MidiInCollector::midiInCallback(HMIDIIN__ * __formal, unsigned int uMsg, unsigned __int64 dwInstance, unsigned __int64 midiMessage, unsigned __int64 timeStamp) Line 226	C++

Thanks for reporting. This should be fixed in d39c332.

1 Like

Thanks again @ed95!