ColorSelector and showSliders crashes


#1

Same code works perfectly for OS X and Windows.  But on Linux the ColorSelector crashes every time if I have 'showSliders' set in the options.  The other options don't make it crash.

This is on Mint17 64bit 


#2

If you're going to make a "it crashed!" post, please always include a stack trace!


#3

I don't build the JUCE libs with debug info, usually.  But here goes:

Program received signal SIGSEGV, Segmentation fault.

0x00007ffff69f5f31 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6

(gdb) bt

#0  0x00007ffff69f5f31 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6

#1  0x00007ffff69fc424 in std::ostreambuf_iterator<char, std::char_traits<char> > std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::_M_insert_float<double>(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, char, double) const ()

   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6

#2  0x00007ffff69fc710 in std::num_put<char, std::ostreambuf_iterator<char, std::char_traits<char> > >::do_put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, double) const () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6

#3  0x00007ffff6a07ca5 in std::ostream& std::ostream::_M_insert<double>(double) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6

#4  0x0000000000472530 in juce::NumberToStringConverters::StackArrayStream::writeDouble (this=0x7fffffffdde8, n=0, numDecPlaces=7)

    at ../../JuceLibraryCode/modules/juce_core/text/juce_String.cpp:459

#5  0x000000000042dd3c in juce::NumberToStringConverters::doubleToString (buffer=0x7fffffffde78 "\250\336\377\377\377\177", numChars=48, n=0, numDecPlaces=7, 

    len=@0x7fffffffde68: 140737488346824) at ../../JuceLibraryCode/modules/juce_core/text/juce_String.cpp:494

#6  0x000000000042dde6 in juce::NumberToStringConverters::createFromDouble (number=0, numberOfDecimalPlaces=7)

    at ../../JuceLibraryCode/modules/juce_core/text/juce_String.cpp:512

#7  0x000000000042dfbc in juce::String::String (this=0x7fffffffdf28, number=0, numberOfDecimalPlaces=7)

    at ../../JuceLibraryCode/modules/juce_core/text/juce_String.cpp:528

#8  0x00000000005104b9 in juce::Slider::getTextFromValue (this=0x210c0e0, v=0) at ../../JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.cpp:1524

#9  0x000000000055a624 in juce::Slider::Pimpl::lookAndFeelChanged (this=0x20d8000, lf=...)

    at ../../JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.cpp:562

#10 0x000000000050ff9d in juce::Slider::lookAndFeelChanged (this=0x210c0e0) at ../../JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.cpp:1452

#11 0x000000000050f7ca in juce::Slider::init (this=0x210c0e0, style=juce::Slider::LinearHorizontal, textBoxPos=juce::Slider::TextBoxLeft)

    at ../../JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.cpp:1362

#12 0x000000000050f63f in juce::Slider::Slider (this=0x210c0e0, name=...) at ../../JuceLibraryCode/modules/juce_gui_basics/widgets/juce_Slider.cpp:1347

#13 0x0000000000731716 in juce::ColourSelector::ColourComponentSlider::ColourComponentSlider (this=0x210c0e0, name=...)

    at ../../JuceLibraryCode/modules/juce_gui_extra/misc/juce_ColourSelector.cpp:29

#14 0x000000000072b473 in juce::ColourSelector::ColourSelector (this=0x2118820, sectionsToShow=15, edge=4, gapAroundColourSpaceComponent=7)

    at ../../JuceLibraryCode/modules/juce_gui_extra/misc/juce_ColourSelector.cpp:322

#15 0x0000000000718241 in MyColourSelector::MyColourSelector (this=0x2118820, g=0x2090490, myflags=15, myedgeGap=4, gapAroundColourSpaceComponent=7)

    at src/juce_colour.cpp:17

 

 


#4

Something looks pretty screwed up there.. Where is the rest of the stack trace showing the place that's actually creating the new MyColourSelector object?


#5

The rest was just in my own code, I don't expect there's anything interesting there.


#6

It's not being invoked from a static constructor, is it?


#7

No, the code is:


gui->handle = new MyColourSelector(gui, 
#ifdef LINUX
                    10  // crash if we set it to 15... or -1
#else
                    -1
#endif
                    ,4, 7); 

The MyColourSelector ctor does the usual dance:


MyColourSelector::MyColourSelector(gui_t *g, int myflags, int myedgeGap, int gapAroundColourSpaceComponent) :
    ColourSelector(myflags, myedgeGap, gapAroundColourSpaceComponent) ,
    ChangeListener()

And its declaration is likewise unremarkable:


class MyColourSelector : public ColourSelector, public ChangeListener

#8

Since it's crashing in the String (double) constructor, have you tried just adding a line of code that does e.g. "String (123.0)" and seeing whether that also crashes? If it does still crash deep inside the C++ standard library like in your stack trace above, it's most likely that you've got some kind of weird compiler/std-library linkage  mismatch rather than this being related to any juce code.

 


#9

That didn't make a difference.  Interestingly, the 32-bit linux build works fine, so it may be something to do with compilation flags 


#10

Turns out it's not compiler flags.  Its the #$@# compiler.

N.B.: don't use gcc 4.8 on linux.  Or for that matter, gcc on any 64-bit intel platform.  It generates *bad* code.

What do I mean by "bad"?  It doesn't take precautions to ensure the stack (RSP) is correctly aligned.  And then it uses the xmm registers with *alignment required* instructions, so you get *random* crashes which depend on ... who knows what?

When I switched to 'clang-3.5' on Linux, this crash (and another one which is ultimately for the same reason) went away.  But not until I lost even more hair.