Hello, guys! I'm facing strange behavior, so I ne...
# multiplatform
r
Hello, guys! I'm facing strange behavior, so I need help. Setup. I have iOS app with two independent KMM libraries, connected to the app with cocoapods as XCFramework. One (my) library is static. The second — dynamic. I'm trying to manually handle exceptions, occured in one KMM library, so I've set unhandled exception hook. The strange part. When exception occurs, I reset std::terminate_handled to the platform default one (I've remembered it on application startup before KN runtime initialization), convert
Throwable
to
NSException
and raise it. I expect that NSException will terminate the app via default platform termination way. But what I see is that terminate_handler from the second KMM library handles it. So I'm observing 5 seconds sleep. In debug session I checking
std::get_tetminate()
just before raising NSException and it is what I set before. I was able to debug the place, where that wrong termination handler appears in native code: raised exception starts handling at
__cxa_begin_catch
. It fetches
__cxa_get_globals()
and then
exception_header
. And there comes wrong KN terminate handler. If I disable second library, everything work as expected. In another sample app with similar setup everything works good and termination handler doesn't replace default. How can that be? I don't see that second library sets own termination handler, I see that my termination handler correctly set, but it doesn't work. I appreciate any suggestion. Thanks!