What causes GC to attempt to free more native bytes than the ones registered as allocated (java.lang.Error: Cleaner terminated abnormally)

Viewed 516

Lately our Android app has been closing without reporting any crash.

After looking into the system dump logs we pinpointed a common log that always appeared when this situation occurred.

Unfortunately we don't have any steps to reproduce it, as it occurs at random points of the app, but we would like to know if someone had any idea of what could be the root cause of this type of issue.

Apparently, when the Garbage Collector started its normal run, it tried to free more native bytes than the ones registered as allocated.

We have had this happen on Android 7 and 8.1 which are the versions that we currently support, using the Samsung Tab A (2016) T585 tablet.

This is the excerpt of the system log:

06-06 11:53:27.243  3954  3965 I art     : Background partial concurrent mark sweep GC freed 189192(8MB) AllocSpace objects, 25(7MB) LOS objects, 40% free, 13MB/22MB, paused 1.940ms total 126.255ms
06-06 11:53:27.244  3954  3962 W System.err: java.lang.Error: Cleaner terminated abnormally
06-06 11:53:27.246  3954  3962 W System.err:    at sun.misc.Cleaner$1.run(Cleaner.java:147)
06-06 11:53:27.246  3954  3962 W System.err:    at sun.misc.Cleaner$1.run(Cleaner.java:145)
06-06 11:53:27.247  3954  3962 W System.err:    at java.security.AccessController.doPrivileged(AccessController.java:41)
06-06 11:53:27.247  3954  3962 W System.err:    at sun.misc.Cleaner.clean(Cleaner.java:144)
06-06 11:53:27.247  3954  3962 W System.err:    at java.lang.ref.ReferenceQueue.enqueueLocked(ReferenceQueue.java:75)
06-06 11:53:27.247  3954  3962 W System.err:    at java.lang.ref.ReferenceQueue.enqueuePending(ReferenceQueue.java:243)
06-06 11:53:27.247  3954  3962 W System.err:    at java.lang.Daemons$ReferenceQueueDaemon.run(Daemons.java:160)
06-06 11:53:27.247  3954  3962 W System.err:    at java.lang.Thread.run(Thread.java:762)
06-06 11:53:27.247  3954  3962 W System.err: Caused by: java.lang.RuntimeException: Attempted to free 98 native bytes with only 91 native bytes registered as allocated
06-06 11:53:27.247  3954  3962 W System.err:    at dalvik.system.VMRuntime.registerNativeFree(Native Method)
06-06 11:53:27.247  3954  3962 W System.err:    at libcore.util.NativeAllocationRegistry.registerNativeFree(NativeAllocationRegistry.java:223)
06-06 11:53:27.247  3954  3962 W System.err:    at libcore.util.NativeAllocationRegistry.-wrap0(NativeAllocationRegistry.java)
06-06 11:53:27.247  3954  3962 W System.err:    at libcore.util.NativeAllocationRegistry$CleanerThunk.run(NativeAllocationRegistry.java:196)
06-06 11:53:27.247  3954  3962 W System.err:    at sun.misc.Cleaner.clean(Cleaner.java:142)
06-06 11:53:27.247  3954  3962 W System.err:    ... 4 more 

I decided to create a Google bug report too.

0 Answers
Related