sweisgerber.dev
sweisgerber.dev

Reputation: 1846

My Application Shuts Down with a Silent Error (AndroidRuntime: Shutting down VM)

MyApplication terminates silently. The last thing it prints is a tracelog from a function, then the Vm shuts down without any reference to my application.

This is the log snippet

05-17 15:25:28.294  4385  4385 D MyApplication: MyFunction()
05-17 15:25:28.294  4385  4385 D AndroidRuntime: Calling main entry com.android.commands.am.Am
05-17 15:25:28.369  4400  4400 W app_process: type=1400 audit(0.0:76): avc: denied { write } for name="system@[email protected]" dev="dm-0" ino=149 scontext=u:r:shell:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=file permissive=0
05-17 15:25:28.419  4400  4400 W main    : type=1400 audit(0.0:77): avc: denied { write } for name="arm64" dev="dm-0" ino=143 scontext=u:r:shell:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=dir permissive=0
05-17 15:25:28.371  4400  4400 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
05-17 15:25:28.375  4400  4400 D AndroidRuntime: CheckJNI is OFF
05-17 15:25:28.417  4400  4400 D ICU     : No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat
05-17 15:25:28.458  4400  4400 I Radio-JNI: register_android_hardware_Radio DONE
05-17 15:25:28.478  4385  4385 D AndroidRuntime: Shutting down VM
05-17 15:25:28.526  4400  4400 D AndroidRuntime: Calling main entry com.android.commands.am.Am
05-17 15:25:28.546  4400  4400 D AndroidRuntime: Shutting down VM

The application continued running. There's no clear indicator except the generic: 05-17 15:25:28.546 4400 4400 D AndroidRuntime: Shutting down VM

Upvotes: 1

Views: 842

Answers (1)

sweisgerber.dev
sweisgerber.dev

Reputation: 1846

The error was caused by an StackOverflow in native code I wrote.

Stackoverflows shut down silently in Android Native Code, in contrast to segfaults and are therefore hard to find.

Locate the last working piece of code with Tracelogging / Logdebug or use the debugger of Android Studio and you will find the location of the bug.

The indicator for the silent termination is: "Shutting down VM"

05-17 15:25:28.478  4385  4385 D AndroidRuntime: Shutting down VM
05-17 15:25:28.526  4400  4400 D AndroidRuntime: Calling main entry com.android.commands.am.Am
05-17 15:25:28.546  4400  4400 D AndroidRuntime: Shutting down VM

The application continued running, because the code was executed within it's own process (via ProcessBuilder.command())

Upvotes: 2

Related Questions