[K/N] Catch exceptions in CAdapters when caches enabled (KT-47828 fixed)

This commit is contained in:
Elena Lepilkina
2021-09-30 10:58:03 +03:00
committed by Space
parent d8b456e8b6
commit c294365068
3 changed files with 14 additions and 8 deletions
@@ -45,6 +45,16 @@ void ThrowException(KRef exception) {
#endif
}
void HandleCurrentExceptionForCInterop() {
try {
std::rethrow_exception(std::current_exception());
} catch (ExceptionObjHolder& e) {
std::terminate(); // Terminate when it's a kotlin exception.
} catch (...) {
throw; // Just rethrow if it's unknown.
}
}
namespace {
class {
@@ -28,6 +28,8 @@ void ThrowException(KRef exception);
void SetKonanTerminateHandler();
void HandleCurrentExceptionForCInterop();
RUNTIME_NOTHROW OBJ_GETTER(Kotlin_getExceptionObject, void* holder);
// The functions below are implemented in Kotlin (at package kotlin.native.internal).