I have a iOS static Framework written in C++, the following piece of code doing some operation by using boost mmaped_file.
When open failed, boost would throw exception out.
However, it will produce a crash like below. It looks like when handling the C++ exception, something goes wrong. And it fallback into a default exception handler which terminate the application.
try {
boost::iostreams::mapped_file mmaped_file;
boost::iostreams::mapped_file_params params;
mmaped_file.open(params)
// doing other operation
}catch (const std::exception &e) {
// write log for exception
log("exception %s", e.what());
}
The boost throw exception like this boost::iostreams::detail::throw_system_failure(msg),
it throws std::ios::failure which is derived from std::exception.
it throw an exception boost::wrapexceptstd::__1::ios_base::failure
but std::ios::failure which is derived from std::exception.
why
try {
boost::iostreams::mapped_file mmaped_file;
boost::iostreams::mapped_file_params params;
mmaped_file.open(params)
// doing other operation
}catch (const std::exception &e) {
// write log for exception
log("exception %s", e.what());
}
why doesn’t this code catch the exception?
However, it works normally on Android and Windows platforms. I wonder if it is caused by a compilation parameter problem?