ofxUI
ofxUI copied to clipboard
Intermitent crash when drawing an ofxUILabel on osx
Does anyone else get a crash when using ofxUILabel? I get a crash (see below for 3 different crash reports for this....all occur in different ways but relate to the same issue) on this say 1 in 5 times that I start my app and was wondering if anyone else had seen something similar?
I realise this is outside of of ofxUI but I've tried to reproduce the error outside of it and can't. I've also looked at where the error is coming from and there is a note in the code about an error but it seems unrelated https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworks/graphics/ofTrueTypeFont.cpp#L974
I also can't find this error being fixed recently https://github.com/openframeworks/openFrameworks/commits/master/libs/openFrameworks/graphics/ofTrueTypeFont.cpp
So just wondering if anyone else has experienced this and how you got around it
BTW im using xcode 5 and ofx 0.74
Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000000013cc
VM Regions Near 0x13cc:
__PAGEZERO 0000000000000000-0000000000001000 [ 4K] ---/--- SM=NUL /Users/USER//IglooMultiScreenWarper.app/Contents/MacOS/IglooMultiScreenWarper
--> VM_ALLOCATE 0000000000001000-00000000000d0000 [ 828K] ---/--- SM=NUL
__TEXT 00000000000d0000-0000000000615000 [ 5396K] r-x/rwx SM=COW /Users/USER//IglooMultiScreenWarper.app/Contents/MacOS/IglooMultiScreenWarper
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 com.igloo.openFrameworks 0x002eadc6 ofTrueTypeFont::getStringBoundingBox(std::string, float, float) + 342 (ofTrueTypeFont.cpp:701) 1 com.igloo.openFrameworks 0x002eabe6 ofTrueTypeFont::stringWidth(std::string) + 70 (ofTrueTypeFont.cpp:661) 2 com.igloo.openFrameworks 0x001273d5 ofxUILabel::setLabel(std::string) + 133 (ofxUILabel.h:187) 3 com.igloo.openFrameworks 0x0012a569 ofxUISlider::updateLabel() + 233 (basic_string.h:279) 4 com.igloo.openFrameworks 0x001361ab ofxUICanvas::loadSpecificWidgetData(ofxUIWidget_, ofxXmlSettings_) + 651 (ofxUICanvas.h:477) 5 com.igloo.openFrameworks 0x00135d51 ofxUICanvas::loadSettings(std::string) + 977 (ofxUICanvas.h:345) 6 com.igloo.openFrameworks 0x001092d4 IglooMultiScreenWarper::setup() + 4964 (basic_string.h:279) 7 com.igloo.openFrameworks 0x000f0f89 ofxFensterManager::runAppViaInfiniteLoop(ofBaseApp_) + 41 (ofxFensterManager.cpp:79) 8 com.igloo.openFrameworks 0x002b790d ofRunApp(ofBaseApp_) + 301 (ofAppRunner.cpp:81) 9 com.igloo.openFrameworks 0x000d1d6b main + 91 (main.cpp:16) 10 libdyld.dylib 0x9b2b970d start + 1
Exception Type: EXC_BAD_ACCESS (SIGBUS) Exception Codes: KERN_PROTECTION_FAILURE at 0x000000000000086c
VM Regions Near 0x86c: --> __PAGEZERO 0000000000000000-0000000000001000 [ 4K] ---/--- SM=NUL /Users/USER/*/IglooMultiScreenWarper.app/Contents/MacOS/IglooMultiScreenWarper VM_ALLOCATE 0000000000001000-0000000000005000 [ 16K] ---/--- SM=NUL
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 com.igloo.openFrameworks 0x0021f97d ofTrueTypeFont::drawChar(int, float, float) + 45 (stl_vector.h:478) 1 com.igloo.openFrameworks 0x002202ca ofTrueTypeFont::drawString(std::string, float, float) + 426 (ofTrueTypeFont.cpp:794) 2 com.igloo.openFrameworks 0x00060589 ofxUILabel::drawFill() + 233 (basic_string.h:279) 3 com.igloo.openFrameworks 0x0005d1fb ofxUIWidget::draw() + 107 (ofxUIWidget.h:94) 4 com.igloo.openFrameworks 0x0006792d ofxUICanvas::draw() + 429 (stl_iterator.h:687) 5 com.igloo.openFrameworks 0x0004fd55 IglooMultiScreenWarper::draw() + 3141 (stl_vector.h:400) 6 com.igloo.openFrameworks 0x0001aaee ofxFenster::draw() + 366 (ofxFenster.cpp:144) 7 com.igloo.openFrameworks 0x0001ede6 Poco::Delegate<ofxFenster, ofEventArgs, false>::notify(void const_, ofEventArgs&) + 70 (ScopedLock.h:69) 8 com.igloo.openFrameworks 0x0001df8a Poco::DefaultStrategy<ofEventArgs, Poco::AbstractDelegate<ofEventArgs> >::notify(void const_, ofEventArgs&) + 58 (stl_iterator.h:675) 9 com.igloo.openFrameworks 0x0001dd0b Poco::AbstractEvent<ofEventArgs, Poco::FIFOStrategy<ofEventArgs, Poco::AbstractDelegate<ofEventArgs> >, Poco::AbstractDelegate<ofEventArgs>, Poco::FastMutex>::notify(void const_, ofEventArgs&) + 235 (AbstractEvent.h:241) 10 com.igloo.openFrameworks 0x000260b6 ofxFensterManager::update() + 262 (ofxFensterManager.cpp:119) 11 com.igloo.openFrameworks 0x00025f98 ofxFensterManager::runAppViaInfiniteLoop(ofBaseApp_) + 56 (ofxFensterManager.cpp:80) 12 com.igloo.openFrameworks 0x001ec90d ofRunApp(ofBaseApp*) + 301 (ofAppRunner.cpp:81) 13 com.igloo.openFrameworks 0x00006d6b main + 91 (main.cpp:16) 14 libdyld.dylib 0x9b2b970d start + 1
Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x00000000a0000844
VM Regions Near 0xa0000844: __LINKEDIT 000000008fe9c000-000000008feaf000 [ 76K] r--/rwx SM=COW /usr/lib/dyld --> Submap 0000000090000000-00000000a0200000 [258.0M] r--/rwx SM=SHM machine-wide VM submap mapped file 0000000090000000-0000000090008000 [ 32K] r-x/r-x SM=COW Object_id=fa4e19a9
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 com.igloo.openFrameworks 0x0023de77 ofTrueTypeFont::getStringBoundingBox(std::string, float, float) + 519 (ofTrueTypeFont.cpp:709) 1 com.igloo.openFrameworks 0x0023dbe6 ofTrueTypeFont::stringWidth(std::string) + 70 (ofTrueTypeFont.cpp:661) 2 com.igloo.openFrameworks 0x0007a3d5 ofxUILabel::setLabel(std::string) + 133 (ofxUILabel.h:187) 3 com.igloo.openFrameworks 0x0007d569 ofxUISlider::updateLabel() + 233 (basic_string.h:279) 4 com.igloo.openFrameworks 0x0008b42a non-virtual thunk to ofxUICanvas::update() + 42 (stl_iterator.h:675) 5 com.igloo.openFrameworks 0x00084d56 Poco::Delegate<ofxUIAppCBGlue, ofEventArgs, false>::notify(void const_, ofEventArgs&) + 70 (ScopedLock.h:69) 6 com.igloo.openFrameworks 0x0003bf8a Poco::DefaultStrategy<ofEventArgs, Poco::AbstractDelegate<ofEventArgs> >::notify(void const_, ofEventArgs&) + 58 (stl_iterator.h:675) 7 com.igloo.openFrameworks 0x0003bd0b Poco::AbstractEvent<ofEventArgs, Poco::FIFOStrategy<ofEventArgs, Poco::AbstractDelegate<ofEventArgs> >, Poco::AbstractDelegate<ofEventArgs>, Poco::FastMutex>::notify(void const_, ofEventArgs&) + 235 (AbstractEvent.h:241) 8 com.igloo.openFrameworks 0x00044098 ofxFensterManager::update() + 232 (ofxFensterManager.cpp:117) 9 com.igloo.openFrameworks 0x00043f98 ofxFensterManager::runAppViaInfiniteLoop(ofBaseApp_) + 56 (ofxFensterManager.cpp:80) 10 com.igloo.openFrameworks 0x0020a90d ofRunApp(ofBaseApp*) + 301 (ofAppRunner.cpp:81) 11 com.igloo.openFrameworks 0x00024d6b main + 91 (main.cpp:16) 12 libdyld.dylib 0x9b2b970d start + 1
I sometimes (like, just now) get a exception in windows in kinda the same place... when reallocating a string. Not sure whether this is from ofxUI corrupting the heap (almost all of my allocations are actually on a seperate heap), but it's certainly a heap corruption and KERN_PROTECTION_FAILURE sounds like it could be a similar thing. (Though I'm not that familiar with deep OSX stuff)
File: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgdel.cpp Line: 52 Expression: _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)
msvcr110d.dll!operator delete(void * pUserData) Line 52 C++
PopTrack_of8_debug.exe!std::allocator::deallocate(char * _Ptr, unsigned int __formal) Line 586 C++
PopTrack_of8_debug.exe!std::_Wrap_alloc<:allocator> >::deallocate(char * _Ptr, unsigned int _Count) Line 888 C++
PopTrack_of8_debug.exe!std::basic_string,std::allocator >::_Tidy(bool _Built, unsigned int _Newsize) Line 2265 C++
PopTrack_of8_debug.exe!std::basic_string,std::allocator >::operator=(std::basic_string,std::allocator > && _Right) Line 920 C++
PopTrack_of8_debug.exe!ofxUILabel::setLabel(std::basic_string,std::allocator > _label) Line 184 C++
> PopTrack_of8_debug.exe!ofxUISlider::updateLabel() Line 405 C++
PopTrack_of8_debug.exe!ofxUISlider::setMaxAndMin(float _max, float _min, bool bKeepValueTheSame) Line 541 C++
PopTrack_of8_debug.exe!ofxUISlider::setMax(float _max, bool bKeepValueTheSame) Line 509 C++
Will update if I find the cause of my problem in case it's related
@sheridanis Most of the time when I get exc_bad_access issues in ofxUI (often a "missing font" that first shows itself in the ofxUILabel of whatever widgets I'm using) it is related to my own memory management. ofxUICanvas allocates a few things dynamically, so it is quite good at bringing up issues with memory management that are actually a result of other parts of your own code.
How are you instantiating ofxUI? Make sure you're managing your memory correctly in all areas of your code related to your ofxUI work - I often forget to reserve space in my vectors before filling them, or I'll accidentally free memory that is pointed to by one object by calling the destructor of another.
Anyway, I'm no expert yet, but hopefully this is of some help!
Hmmm I spoke too soon, just updated ofxUI and now i'm also getting the ofTrueTypeFont::getStringBoundingBox via ofxUIDropDownList::setShowCurrentSelected(true);
checkAndSetTitleLabel
setLabelText
ofxUILabel::setLabel
ofTrueTypeFont::stringWidth
getStringBoundingBox
NOTE- I just got rid of the 'setShowCurrentSelected(true);' line in my code and i'm not getting that exception anymore
Been getting this a lot lately in an intense processing app (with about 30 sliders, all being constantly changed) Removing the line in ofxUISlider::updateLabel made the problem go away and hasn't been back since...
I'm breaking up the line, (into the below code) and so far no problems... though it could be a co-incidence (and not working on the intense code atm)
std::string Label;
Label = name;
Label += ": ";
Label += ofxUIToString(getScaledValue(),labelPrecision);
// label->setLabel(name + ": " + ofxUIToString(getScaledValue(),labelPrecision));
label->setLabel( Label );
Next chance I get I'll do some more detailed debugging, I'm assuming there's a static or temporary deep in this code somewhere that's being trashed (and maybe due to some multi-threaded stuff on my side)
Thanks for diving into this issue guys. Also, I've changed the minimum openframeworks version to 0.8.0, so that might be why getStringBoundingBox is throwing an error, unless it was included in of 0.7.4... keep me updated.
anyone got an update on this?
Still no crashes since changing code to the above...
Just something I've noticed, I get the "getstringboundingbox" error whenever I use
ofxUICanvas::addTextInput(etc)
however I don't get it when I use
ofxUICanvas::addWidgetDown(new ofxUITextInput(etc))
I haven't looked much further into it yet, but perhaps it is worth checking out what's happening differently behind the scenes for both of these different methods. Btw I was using a ofxUISuperCanvas when I came across this, not sure if is same for regular canvas.
I changed all of my addTextInput calls to addWidgetDown and I still get similar errors (see below) every 3rd or 4th time I run my app.......although I'm using ofx0.74 so I'll try 0.8 soon.
0 com.igloo.openFrameworks 0x00250f86 ofTrueTypeFont::getStringBoundingBox(std::string, float, float) + 342 (ofTrueTypeFont.cpp:701) 1 com.igloo.openFrameworks 0x00250da6 ofTrueTypeFont::stringWidth(std::string) + 70 (ofTrueTypeFont.cpp:661) 2 com.igloo.openFrameworks 0x0008d5b5 ofxUILabel::setLabel(std::string) + 133 (ofxUILabel.h:187) 3 com.igloo.openFrameworks 0x00090749 ofxUISlider::updateLabel() + 233 (basic_string.h:279) 4 com.igloo.openFrameworks 0x0009c38b ofxUICanvas::loadSpecificWidgetData(ofxUIWidget_, ofxXmlSettings_) + 651 (ofxUICanvas.h:477) 5 com.igloo.openFrameworks 0x0009bf31 ofxUICanvas::loadSettings(std::string) + 977 (ofxUICanvas.h:345)
My code change above finally crashed. So it's not anything related to the string...
What ofx version are you using graham?
My last sync with the develop branch was the start of february...when they did all the .gitignore changes
Am I the only one using labels multithreaded? I think my case might purely be being thread un-safe
@SoylentGraham I have the same problem in OSX. It started after I changed the font I was using applying setFont(xxxx.ttf) to a GUI Tab bar object.
I'm sure mine was just due to multiple threads changing the label at the same time I'm afraid