Crash when moving the cursor over a juce::TextEditor component

Hi all,

I’m writing a JUCE app (JUCE v5.4.7) for Linux and I want to make sure the binary works in other distributions (dynamic linking, missing dependencies and such). So I build the source code on a Linux machine (Ubuntu 18.04, with GCC v7.5) and then I move the executable to another Linux machine (virtualized Ubuntu 18.04 with VirtualBox).

Now, if I run the app in the virtualized Ubuntu, a segmentation fault is triggered as soon as the mouse cursor is moved over a juce::TextEditor component, with the following backtrace:

#0  0x00007ffff7da6ec8 in XFreeCursor () from /lib/x86_64-linux-gnu/libX11.so.6
#1  0x00005555559774af in juce::MouseCursor::showInWindow (this=0x7fffffffd9f0, peer=0x555555fd61c0)
    at ../../../../JUCE/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp:4129
#2  0x000055555598898a in juce::MouseInputSourceInternal::showMouseCursor (this=0x555555fd5670, cursor=..., forcedUpdate=false)
    at ../../../../JUCE/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp:490
#3  0x0000555555988a9c in juce::MouseInputSourceInternal::revealCursor (this=0x555555fd5670, forcedUpdate=false)
    at ../../../../JUCE/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp:506
#4  0x0000555555987a95 in juce::MouseInputSourceInternal::setComponentUnderMouse (this=0x555555fd5670, newComponent=0x555555fe2338, screenPos=..., time=...)
    at ../../../../JUCE/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp:252
#5  0x0000555555987bf2 in juce::MouseInputSourceInternal::setScreenPos (this=0x555555fd5670, newScreenPos=..., time=..., forceUpdate=false)
    at ../../../../JUCE/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp:270
#6  0x0000555555987fc8 in juce::MouseInputSourceInternal::handleEvent (this=0x555555fd5670, newPeer=..., positionWithinPeer=..., time=..., newMods=..., newPressure=0, 
    newOrientation=0, pen=...) at ../../../../JUCE/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp:340
#7  0x00005555558e4fb9 in juce::MouseInputSource::handleEvent (this=0x7fffffffdc40, peer=..., pos=..., time=1591349070835, mods=..., pressure=0, orientation=0, penDetails=...)
    at ../../../../JUCE/modules/juce_gui_basics/mouse/juce_MouseInputSource.cpp:634
#8  0x0000555555963325 in juce::ComponentPeer::handleMouseEvent (this=0x555555fd61c0, type=juce::MouseInputSource::mouse, pos=..., newMods=..., newPressure=0, newOrientation=0, 
    time=1591349070835, pen=..., touchIndex=0) at ../../../../JUCE/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp:88
#9  0x00005555559c4cbe in juce::LinuxComponentPeer::handleMotionNotifyEvent (this=0x555555fd61c0, movedEvent=...)
    at ../../../../JUCE/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp:1927
#10 0x00005555559c3fe2 in juce::LinuxComponentPeer::handleWindowMessage (this=0x555555fd61c0, event=...)
    at ../../../../JUCE/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp:1639
#11 0x0000555555975a12 in juce::WindowingHelpers::windowMessageReceive (event=...)
    at ../../../../JUCE/modules/juce_gui_basics/native/juce_linux_X11_Windowing.cpp:3478
#12 0x00005555559735e7 in juce::XWindowSystem::<lambda(int)>::operator()(int) const (__closure=0x555555fd4f90)
    at ../../../../JUCE/modules/juce_gui_basics/native/juce_linux_X11.cpp:217
#13 0x000055555597bf2d in std::_Function_handler<void(int), juce::XWindowSystem::initialiseXDisplay()::<lambda(int)> >::_M_invoke(const std::_Any_data &, int &&) (__functor=..., 
    __args#0=@0x7fffffffde74: 5) at /usr/include/c++/8/bits/std_function.h:297
#14 0x00005555557f716a in std::function<void (int)>::operator()(int) const (this=0x555555fd4f90, __args#0=5) at /usr/include/c++/8/bits/std_function.h:687
#15 0x00005555557f3243 in juce::InternalRunLoop::dispatchPendingEvents (this=0x555555fd4ee0)
    at ../../../../JUCE/modules/juce_events/native/juce_linux_Messaging.cpp:186
#16 0x00005555557ee737 in juce::MessageManager::dispatchNextMessageOnSystemQueue (returnIfNoPendingMessages=false)
    at ../../../../JUCE/modules/juce_events/native/juce_linux_Messaging.cpp:294
#17 0x00005555557e95b3 in juce::MessageManager::runDispatchLoop (this=0x555555fd4e70)
    at ../../../../JUCE/modules/juce_events/messages/juce_MessageManager.cpp:128
#18 0x00005555557e8afb in juce::JUCEApplicationBase::main () at ../../../../JUCE/modules/juce_events/messages/juce_ApplicationBase.cpp:262
#19 0x00005555557e8a0c in juce::JUCEApplicationBase::main (argc=1, argv=0x7fffffffe0f8)
    at ../../../../JUCE/modules/juce_events/messages/juce_ApplicationBase.cpp:240
#20 0x00005555555e025c in main (argc=1, argv=0x7fffffffe0f8) at ../../Source/Main.cpp:106

Additional information:

  • I tested other non-JUCE apps that need to change the cursor shape, built the same way I did for the JUCE one, and no crash occurred;
  • the segfault is reproducible in other Ubuntu versions (e.g. 19.04);
  • the app no longer crashes if I change the keyboard layout to English US (default) to any other one (my physical keyboard has a non-US layout) (this is weird).

I’m not sure where the problem is coming from - JUCE, Ubuntu, VirtualBox, all of them? Any input is welcome…

1 Like

This has been fixed on the develop branch now in 945cf12.

4 Likes