kiwix-android
kiwix-android copied to clipboard
Android apps should catch & handle JNI crashes as exception
From @kelson42 on September 26, 2016 10:57
To avoid any wild crashes of the apps. Here is a how to: http://blog.httrack.com/blog/2013/08/23/catching-posix-signals-on-android/
Copied from original issue: kiwix/kiwix#330
This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.
This requires a kiwix-lib update, the native code must re-throw exceptions as java ones for the android app to begin handling them.
@macgills I think:
- Newer version of the libkiwix tends to generate exceptions (general approach)
- The JNI tends to catch them already.
@mhutti1 @macgills Could you confirm? If the libkiwix does not behaves properly from your perspective, please open a ticket and linked it here. But, I believe this ticket can be closed.
This ticket cannot be closed. When the native code causes an error we get fatal signals, such errors are present in 2.5.1
If Java Exceptions were getting thrown I would get a stacktrace for such an error but what actually happens is I get this
Once it is actually throwing exceptions then on the android side we must catch them.
I think this is a crash of the libzim, so a bug in it. You can not handle that neither in c++ nor in Java IMO. Do you have a reprocase for that?
I have absolutely no idea how that crash happened but the library @mhutti1 linked to claims it can catch SIGSEGV signals and if that was the case I would have a stacktrace and at least some idea of what code execution caused it.
OK, thx for the explanation. Then, yes, if CoffeCatch works, then it should be setup.
@mgautierfr I believe this issue should be moved to kiwix-lib, can you confirm this?
I am moving this ticket to 3.1, @mgautierfr if you can review the information on this ticket and give your opinion on it's viability we can progress with it
Yes it is feasible. At least we will be able to have some trace and solve issues.
Next question will be : "What to do when native code crash ?" If we crash because of a sigsegv, the library is in an undefined state so unusable.
Is there much internal state of the library? Can we supply a method to reset the state of the library. On android we can relaunch the process which is fairly nasty but gives you a guarantee there is no lingering state
This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.
@macgills Your last comment would probably benefit of a dedicated ticket on the kiwix-lib repo.
@macgills We can not fix this ticket now. Postponing..
This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.
@mgautierfr @macgills I believe it would be good to implement this if this is the path to follow to be able to investigate properly crash reports. Does that sounds doable now?
This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.