I’m developing an app that reads serial data that’s sent every frame by an Arduino, stores it, displays it and forwards some events via OSC.
Every few launches I get a crash that I haven’t been able to trace. It’s a vector std::out_of_range exception in this line of executeLaunch (this one in the implementation file).
I have no idea what vector is causing the crash and I haven’t been able to replicate it in a separate app yet. Any tips on debugging these kinds of things?
Thanks Rich. I’m doing that already, but I can’t really step in or out of executeLaunch(). The debugger drops me there even though I have my setup, update and draw surrounded by try/catch.
That catch in excecuteLaunch() will only be hit if the exception goes uncaught. Perhaps the exception is happening on a background thread?
In any event, make sure you are breaking on the throw, if that is working then it should break you right where the std::vector::at() was called with an out of bounds argument.
Awesome, that worked. Never used that kind of breakpoints before, thanks.
EDIT: actually, my main error was writing ci::Exception in my catch statements, which wasn’t working in this case because this was an std::exception. Just in case it helps someone else in the future.
ci::Exception inherits from std::exception, so a properly-written catch block can catch either. Just make sure you are catching by const reference so polymorphism is possible.
Never mind the catch block I wrote previously. The type polymorphism only accepts downstream variants, so catching std::exception will work for ci::Exception, but not the other way around.