Android illegal memory access - who and how is it handled?

298 views Asked by At

I am trying to debug a problem in which an application is triggering continuous data aborts due to invalid memory access.

I have following queries.

  1. In general when an application in Android(CPU ARM) is accessing an invalid memory access, what happens?

    I guess a page fault would occur and then a data abort would be triggered. Is it so? Could someone briefly explain how does Android handle invalid memory access?

  2. What happens to the process which makes illegal memory access? Is it restarted again and again or is it killed? Who handles this?

I would like some references to the code(only if possible). Thank you.

1

There are 1 answers

0
auselen On

Android is built on top of Linux. So your questions are actually how Linux handles those which there should be plenty of pointers on the web.

In general when an application does illegal memory access that is memory addresses not mapped to your application, Linux will send a SIGSEGV signal to the application and if not handled will kill it while producing some useful logs in the kernel log (dmesg, /proc/kmsg).

Android might also create tombstones under /data/tombstone and put some extra detailed information in android log buffers (adb logcat).

Normally when an process dies in Linux, Linux doesn't do anything special about it but then you might have some higher level of application life cycle management which would do some extra steps.

Android just create an ~"unexpected app crash" dialog for normal applications but for services or apps (like homescreen) that needs to be kept alive it would restart them with some logic to avoid continuous respawn of erroneous services.

It is not possible to find single points in code base that does all of these since it is logic spread among different parts, layers.