I was experimenting with CryptoPP library and I noticed it crashes in some cases, on investigating further, I saw that when it threw an exception, on linux it caught it too , but on android, it doesnt. So i made a very simple sanity check, here it is :
void random_test() {
LOGD("EXCEPTION : THROW ");
throw Exception();
}
And then I call it so :
try {
random_test();
} catch (Exception e ) {
LOGD("EXCEPTION CAUGHT");
}
It doesnt go to Exception caught. This is the output from logcat:
2022-07-07 01:54:23.156 24102-24186/ D/JNIpart: EXCEPTION : THROW 2022-07-07 01:54:23.157 24102-24186/ E/libc++abi: terminating with uncaught exception of type cv::Exception
Then I tried this
try {
random_test();
} catch (...) {
LOGD("EXCEPTION CAUGHT");
}
And this catches the exception.
Now in CryptoPP library: https://github.com/weidai11/cryptopp/blob/9ea66ce4d97d59d61e49c93f5af191107ebd1925/asn.cpp#L559 This is where exception is thrown, and when we try to catch it like this :
catch (const BERDecodeErr e)
{
LOGD("QRCPP : CATCH THE EXCEPTION FFS %s ", e.what());
}
And the code still crashes, even with this code :
catch (...)
{
LOGD("QRCPP : CATCH THE EXCEPTION FFS %s ", e.what());
}