Do the various setBounds() methods require ints?


#1

Hi all,

I’ve implemented resizing in my latest plugin, where all of the setBounds() coordinates are expressed as functions of a single master size. However, my plugin is occasionally crashing Ableton Live when it opens up and I change a parameter with the mouse. I am wondering if this is due to using floating point numbers for the setBounds() values. Do these need to be converted to ints?

Here’s the crash log, in case this helps determine what is going on. It is worth noting this only happens with the VST - the AU works fine in Live. Would this crash be caused by floating point values for setBounds()?

[code]Process: Live [738]
Path: /Live 8.2.2/Live.app/Contents/MacOS/Live
Identifier: com.ableton.live
Version: 8.2.2 (8.2.2)
Code Type: X86 (Native)
Parent Process: launchd [101]

Date/Time: 2011-08-05 17:47:54.976 -0700
OS Version: Mac OS X 10.6.4 (10F569)
Report Version: 6

Interval Since Last Report: 1426109 sec
Crashes Since Last Report: 52
Per-App Interval Since Last Report: 586453 sec
Per-App Crashes Since Last Report: 37
Anonymous UUID: DF7F5957-029D-4CBC-8408-7EEB35B81587

Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000000000008
Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 …hallaDSP.ValhallaChorusPlus 0x1a52d9e2 void juce::ListenerList<juce::ChangeListener, juce::Array<juce::ChangeListener*, juce::DummyCriticalSection> >::calljuce::ChangeBroadcaster*(void (juce::ChangeListener::)(juce::ChangeBroadcaster), juce::TypeHelpers::ParameterTypejuce::ChangeBroadcaster*::type) + 66 (juce_ListenerList.h:170)
1 …hallaDSP.ValhallaChorusPlus 0x1a458aa3 juce::ChangeBroadcaster::callListeners() + 57 (juce_ChangeBroadcaster.cpp:99)
2 …hallaDSP.ValhallaChorusPlus 0x1a458b45 juce::ChangeBroadcaster::ChangeBroadcasterCallback::handleAsyncUpdate() + 155 (juce_ChangeBroadcaster.cpp:111)
3 …hallaDSP.ValhallaChorusPlus 0x1a56ad7e juce::AsyncUpdaterMessage::messageCallback() + 64 (juce_AsyncUpdater.cpp:48)
4 …hallaDSP.ValhallaChorusPlus 0x1a490922 juce::MessageManager::deliverMessage(juce::Message*) + 116 (juce_MessageManager.cpp:112)
5 …hallaDSP.ValhallaChorusPlus 0x1a6f195f juce::MessageQueue::deliverNextMessage() + 113 (juce_osx_MessageQueue.h:78)
6 …hallaDSP.ValhallaChorusPlus 0x1a6f19ee juce::MessageQueue::runLoopCallback() + 26 (juce_osx_MessageQueue.h:84)
7 …hallaDSP.ValhallaChorusPlus 0x1a6f1a33 juce::MessageQueue::runLoopSourceCallback(void*) + 17 (juce_osx_MessageQueue.h:94)
8 com.apple.CoreFoundation 0x946c90fb __CFRunLoopDoSources0 + 1563
9 com.apple.CoreFoundation 0x946c6bbf __CFRunLoopRun + 1071
10 com.apple.CoreFoundation 0x946c6094 CFRunLoopRunSpecific + 452
11 com.apple.CoreFoundation 0x946c5ec1 CFRunLoopRunInMode + 97
12 com.apple.HIToolbox 0x95c7df9c RunCurrentEventLoopInMode + 392
13 com.apple.HIToolbox 0x95c7dd51 ReceiveNextEventCommon + 354
14 com.apple.HIToolbox 0x95c7dbd6 BlockUntilNextEventMatchingListInMode + 81
15 com.apple.AppKit 0x90b98a89 _DPSNextEvent + 847
16 com.apple.AppKit 0x90b982ca -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 156
17 com.apple.AppKit 0x90b5a55b -[NSApplication run] + 821
18 com.ableton.live 0x0160b2b4 std::out_of_range::~out_of_range() + 4774564
19 com.ableton.live 0x015fd92c std::out_of_range::~out_of_range() + 4718876
20 com.ableton.live 0x00181f8e std::map<int*, CInterprocessCommsAudioQueueRefCountStruct*, std::less<int*>, std::allocator<std::pair<int* const, CInterprocessCommsAudioQueueRefCountStruct*> > >::map() + 820
21 com.ableton.live 0x00181eb5 std::map<int*, CInterprocessCommsAudioQueueRefCountStruct*, std::less<int*>, std::allocator<std::pair<int* const, CInterprocessCommsAudioQueueRefCountStruct*> > >::map() + 603

[/code]

Thanks,

Sean Costello


#2

I don’t understand what you mean… C++ is a statically typed language: it’s impossible to call setBounds with anything that isn’t an int…(??)


#3

Well, here’s a snippet of my code:

// set the positions for all the slider labels and sliders. 
// first, do the mix slider, which has a button for its label
 chorusSlider[0]->setBounds(10.f*guiSize, (LOGO_HEIGHT+25.f)*guiSize, SLIDER_WIDTH*guiSize, SLIDER_HEIGHT*guiSize);
	 
// now do the next 4 sliders and their labels
for(int j=1;j<5;j++)
{
	chorusSliderLabel[j]->setBounds ((10.f+(float(j)*SLIDER_WIDTH))*guiSize, LOGO_HEIGHT*guiSize, SLIDER_WIDTH*guiSize, 20.f*guiSize);
	chorusSlider[j]->setBounds((10.f+(float(j)*SLIDER_WIDTH))*guiSize, (LOGO_HEIGHT+25.f)*guiSize, SLIDER_WIDTH*guiSize, SLIDER_HEIGHT*guiSize);
}

SLIDER_WIDTH, LOGO_HEIGHT, and guiSize are all declared as floats.

Compiling this doesn’t throw any errors. However, I do get the crash as detailed above. Are these linked?


#4

Well the compiler should give you some warnings about the float->int loss of precision! It’s implicitly converting your floats to ints (obviously… or did you think that all the ints inside the setBounds function would just magically behave as floats if that’s what you try to pass to it??)

No.


#5

[quote=“jules”]Well the compiler should give you some warnings about the float->int loss of precision! It’s implicitly converting your floats to ints (obviously… or did you think that all the ints inside the setBounds function would just magically behave as floats if that’s what you try to pass to it??)
[/quote]

Honestly, I hadn’t paid much attention to setBounds() in the past.

[quote]

No.[/quote]

Well, then, any idea what is causing the bug I listed? Because, well, having a plugin crash isn’t really good, and the bug never happened before having a resizable GUI.


#6

Looks like a dangling pointer to me. Use your debugger!


#7

It looks like I had commented out removeChangeListener() in the destructor of my editor. Does this seem like a likely suspect?


#8

Yes, it does!