When Halide is built with exceptions enabled (generally the default these days because it's required for PyBind), all of our Error types (and internal_assert, etc) throw exceptions, rather than log-to-stderr-and-exit.
This is a problem for the many, many tests we have that are JIT-based, because they have no try/catch blocks, and when C++ throws an exception with no enclosing catch block, it just calls std::terminate(), which defaults to simply calling abort().
AFAIK, there is no C++-standards-complaint way to install a handler to "catch unhandled exceptions", though MSVC/Win32 provides a way, and anecdotally there are ways to get gcc/g++ to do something similar; it would be good to try to handle this.
And/or, we could add some sort of minimal test framework to our JIT-based tests to ensure that everything is wrapped in try/catch.
When Halide is built with exceptions enabled (generally the default these days because it's required for PyBind), all of our
Errortypes (andinternal_assert, etc) throw exceptions, rather than log-to-stderr-and-exit.This is a problem for the many, many tests we have that are JIT-based, because they have no try/catch blocks, and when C++ throws an exception with no enclosing catch block, it just calls
std::terminate(), which defaults to simply callingabort().AFAIK, there is no C++-standards-complaint way to install a handler to "catch unhandled exceptions", though MSVC/Win32 provides a way, and anecdotally there are ways to get gcc/g++ to do something similar; it would be good to try to handle this.
And/or, we could add some sort of minimal test framework to our JIT-based tests to ensure that everything is wrapped in try/catch.