Component::addToDesktop crashes in SSH session on Windows

This is an interesting one. We are using catch based unit tests in our CI and due to the way our Jenkins setup works, the test executables are executed in SSH sessions. Now when we started updating all our existing plugins to JUCE 8 in the last months, we noticed mysterious unit test failures on Windows only that no one could reproduce locally. It took us quite a while to get to the bottom of it.

The problem turned out to be juce::Component::addToDesktop which only crashes in a headless Windows SSH session. This function happens to be called in some of our in-house UI design helper classes and the tests crash in a case where a plugin editor instance is created in a unit test case (without actually being displayed). We could track down the crash somewhere down in getMonitorFromOutput in juce_VBLank_windows.cpp where it seems as if the output passed to that function is a nullptr.

We tried to apply a quick fix ourselves that returned a nullptr from that function in case output is null but that seems to break stuff in other places. To be honest, nobody from our team really feels confident editing stuff in this area of the JUCE code.

Would be happy if you could take a look at the issue as this would probably fix our failing unit tests again.

Here is a simple command line app to reproduce the issue, it works without SSH but crashes for an SSH connection:

#include <juce_gui_basics/juce_gui_basics.h>

int main()
{
    std::cout << "Startup..." << std::endl;
    
    juce::ScopedJuceInitialiser_GUI initialiser;
    juce::Component component;
    component.addToDesktop (juce::ComponentPeer::StyleFlags::windowIgnoresKeyPresses);

    std::cout << "Alright, we reached this point without crashing" << std::endl;
    return 0;
}

Thanks for reporting this issue. A fix is now available on the develop branch:

1 Like

Wow, that was a really quick fix, thanks a lot! Will check it out as soon as possible…