OpenImageIO icon indicating copy to clipboard operation
OpenImageIO copied to clipboard

fix: Don't let fmtlib exceptions crash the app

Open lgritz opened this issue 1 year ago • 0 comments
trafficstars

When fmt arguments don't match the format string, fmt will throw an exception, or terminate if we disable exceptions (which we do). For gcc11+, we tried intercepting these, but let's do it for all platforms, and let's not terminate ourselves, but insted print and log the error.

But, oof, to do this properly, I needed to move some error recording functionality from libOpenImageIO to libOpenImageIO_Util and make it owned more properly by strutil.cpp, so that this all works even when only using the util library. The logic isn't changing, it's just moving over to the other library.

This all helps to address #4388

Unfortunately, the exception thrown by fmt doesn't tell us the bad format string itself. That would have really allowed to probably zero right in on it. But at least we know it's occurring, and one could put a breakpoint on pvt::log_fmt_error to catch it in the act and see where it's being called, revealing the bad line.

lgritz avatar Aug 28 '24 22:08 lgritz