SIGSEGV when running gui-less app in Debug mode


I tried to run my unit-tests binary in Debug mode and got a core dump which didn’t appear when in Release mode. The program is in console mode so it has no GUI but still uses the messaging facility.

Here is the stack:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1214318912 (LWP 8330)]
0xb7e54abb in XLockDisplay () from /usr/lib/
(gdb) bt
#0  0xb7e54abb in XLockDisplay () from /usr/lib/
#1  0x0811490f in ScopedXLock (this=0xbffcce83) at ../../src/native/linux/juce_linux_Messaging.cpp:43
#2  0x08114aa6 in juce::MouseCursor::deleteMouseCursor (cursorHandle=0x0) at ../../src/native/linux/juce_linux_Windowing.cpp:3066
#3  0x080bba90 in ~SharedCursorHandle (this=0x831ea60) at ../../src/gui/components/mouse/juce_MouseCursor.cpp:120
#4  0x080bbb42 in juce::MouseCursor::SharedCursorHandle::release (this=0x831ea60) at ../../src/gui/components/mouse/juce_MouseCursor.cpp:90
#5  0x080bb101 in ~MouseCursor (this=0xbffcd054) at ../../src/gui/components/mouse/juce_MouseCursor.cpp:151
#6  0x0808f7c9 in ~Component (this=0xbffcd01c) at ../../src/gui/components/juce_Component.cpp:109
#7  0x0809ad33 in ~Button (this=0xbffcd01c) at ../../src/gui/components/buttons/juce_Button.cpp:87
#8  0x0809cad0 in ~TextButton (this=0xbffcd01c) at ../../src/gui/components/buttons/juce_TextButton.cpp:44
#9  0x0807dec9 in juce::initialiseJuce_GUI () at ../../src/core/juce_Initialisation.cpp:133
#10 0x08056793 in main (argc=1, argv=0xbffcd1d4) at ../../src/test/main.cpp:15

The incriminated code of initialiseJuce_GUI is the following:

      #if JUCE_DEBUG
        // This section is just for catching people who mess up their project settings and
        // turn RTTI off..
            TextButton tb (String::empty);
            Component* c = &tb;

            // Got an exception here? Then TURN ON RTTI in your compiler settings!!
            c = dynamic_cast <Button*> (c);
        catch (...)
            // Ended up here? If so, TURN ON RTTI in your compiler settings!!

I’m using Juce v1.52.69 but this part of the code hasn’t changed in the tip either.
I guess this could be solved by using another pair of classes to test the presence of RTTI, but does that mean I could encounter other problems later on, even though the binary seems to run well in Release mode?

Yes, that test should definitely use some non-UI classes - I’ll sort that out. I doubt if you’ll see any other problems unless you use UI classes yourself.

Allright. Thanks a lot Jules!