I’m working under OS X 10.10, OF_v0.8.4 and Xcode 6.1. I’ve been frequently having exc_bad_access errors while using ofPtr shared pointers. Somehow the pointer gets corrupt and Xcode throws this error. For instances
int channel = 0;
int id = 0;
int width = 4;
int height = width;
BasicVisual visual(position, width, height);
vector< ofPtr<Led> > leds;
ofPtr<Led> led = ofPtr<Led> (new Led ( visual, id, channel ) );
The funny thing is that it only happens in Release Mode but not in Debug Mode.
Do you have any idea why?
Thank you in advance.
are you using threads? segmentation faults that happen only in release are usually due to race conditions between threads, the problem happens more often in release because it’s quicker. ofPtr is just shared_ptr from standard c++ so there shouldn’t be any problem with it
In fact, it was everything running in the main thread. It wasn’t indeed a problem of the shared_ptr. Actually, “vector< ofPtr > leds” was declared as a member data, but for simplification issues I posted it in the OF Forum as locally declared. However, at that point it gets corrupted or freed, but only in Release mode. I compiled it under Linux and Windows and it were running fine.
I couldn’t find what was the problem, so I did a fresh install of Xcode, downloaded again OF_v0.8.4 and now it seems be running fine for the moment. If it occurs again I will do further investigations.
Thanks for help and for stressing the multithreading possible issue.
oh, sometimes in xcode you get this weird crashes that seem to make no sense, it’s usually solved by cleaning and rebuilding