kiwix-android icon indicating copy to clipboard operation
kiwix-android copied to clipboard

Android apps should catch & handle JNI crashes as exception

Open mhutti1 opened this issue 8 years ago • 17 comments

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

mhutti1 avatar Mar 18 '17 12:03 mhutti1

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.

stale[bot] avatar Jun 26 '19 07:06 stale[bot]

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 avatar Jul 15 '19 11:07 macgills

@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.

kelson42 avatar Jul 15 '19 14:07 kelson42

This ticket cannot be closed. When the native code causes an error we get fatal signals, such errors are present in 2.5.1 image If Java Exceptions were getting thrown I would get a stacktrace for such an error but what actually happens is I get this image Once it is actually throwing exceptions then on the android side we must catch them.

macgills avatar Jul 15 '19 15:07 macgills

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?

kelson42 avatar Jul 15 '19 15:07 kelson42

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.

macgills avatar Jul 15 '19 15:07 macgills

OK, thx for the explanation. Then, yes, if CoffeCatch works, then it should be setup.

kelson42 avatar Jul 15 '19 15:07 kelson42

@mgautierfr I believe this issue should be moved to kiwix-lib, can you confirm this?

macgills avatar Aug 21 '19 10:08 macgills

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

macgills avatar Sep 03 '19 14:09 macgills

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.

mgautierfr avatar Sep 03 '19 15:09 mgautierfr

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

macgills avatar Sep 03 '19 15:09 macgills

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.

stale[bot] avatar Nov 02 '19 15:11 stale[bot]

@macgills Your last comment would probably benefit of a dedicated ticket on the kiwix-lib repo.

kelson42 avatar Nov 03 '19 17:11 kelson42

@macgills We can not fix this ticket now. Postponing..

kelson42 avatar Nov 06 '19 15:11 kelson42

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.

stale[bot] avatar Jan 05 '20 16:01 stale[bot]

@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?

kelson42 avatar Jul 10 '20 08:07 kelson42

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.

stale[bot] avatar Oct 17 '20 02:10 stale[bot]