JUCE crashing when Logic is opened

I’ve been programming my JUCE app all day yesterday without any crashes.
All of a sudden it crashed on launch every time. It took me a while to figure out that it was because I had Logic Pro X opened on the same machine.

My app is using JUCE’s AudioDeviceManager and I’m using a modified piece of sample code to get all audio output devices in the system and play out to the one the user selected in the preferences.
Turns out that if Logic is opened on the same machine and the AudioDeviceManager loads devices, it crashes on startup.

The crash source is unfortunately rather hard to find. I’m getting a EXC_BAD_ACCESS in juce_osx_MessageQueue->deliverNextMessage. Often times I’m getting a C++ exception instead of the EXC_BAD_ACCESS: “libc++abi.dylib: Pure virtual function called!”

I had occasional crashes before when Logic or Pro Tools was opened but it wasn’t consistent enough to investigate further. This time it’s repeatable and happens in 90% of all cases.

Here’s the code I’m using to load the audio devices:

AudioDeviceManager dm;
OwnedArray<AudioIODeviceType> types;

for (int i = 0; i < types.size(); ++i)
    String typeName (types[i]->getTypeName());  // This will be things like "DirectSound", "CoreAudio", etc.
    types[i]->scanForDevices();                 // This must be called before getting the list of devices
    StringArray deviceNames (types[i]->getDeviceNames());  // This will now return a list of available devices of this type
    for (int j = 0; j < deviceNames.size(); ++j)
        AudioIODevice* device = types[i]->createDevice(deviceNames[j], String());
        if (device->getName() == "AirPlay")
            delete device;
        AudioDevice::Ptr oneDevice = std::make_shared<AudioDevice>(device, 48000.0, 512);

Grateful for any insights you might have! Thanks!