okio.Base64.encode ArrayIndexOutOfBoundsException why is that even happening?

Viewed 733

I noticed such exception in fabric, which is occurring rarely but with every build, 3-5 crashes every week on 2-3 users (from ~500 DAU) I didn't found any information about such crashes, does anyone knows what causes them?

I've found only one question about such issue but it was deleted as "duplicate" https://stackoverflow.com/questions/45868217/arrayindexoutofboundsexception-trying-to-cache-certificate-list-in-okhttp3

Fatal Exception: java.lang.ArrayIndexOutOfBoundsException
length=1305; index=1953974520

okio.Base64.encode (Base64.java:137)
okio.Base64.encode (Base64.java:125)
okio.ByteString.base64 (ByteString.java:105)
okhttp3.Cache$Entry.writeCertList (Cache.java:686)
okhttp3.Cache$Entry.writeTo (Cache.java:645)
okhttp3.Cache.put (Cache.java:249)
okhttp3.Cache.access$000 (Cache.java:136)
okhttp3.Cache$1.put (Cache.java:148)
okhttp3.internal.cache.CacheInterceptor.maybeCache (CacheInterceptor.java:173)
okhttp3.internal.cache.CacheInterceptor.intercept (CacheInterceptor.java:143)
okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:92)
okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:67)
okhttp3.internal.http.BridgeInterceptor.intercept (BridgeInterceptor.java:93)
okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:92)
okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept (RetryAndFollowUpInterceptor.java:124)
okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:92)
okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:67)

UPDATE:

https://github.com/square/okio/issues/325 Okio ticket for this issue https://issuetracker.google.com/issues/69364976 Google ticket for this issue

UPDATE 2: was fixed in Android Studio 3.1 Canary 6 Build

2 Answers

It’s a bug in either the VM or the infrastructure around the VM (the CPU?, the memory?). There’s no other way a value i, that loops between 0 and an array’s length, can go out of bounds like this.

It is probably bug in VM at particular devices starting from 8 of November only on Android 5.1.

We have found out that the problem is caused by using dex compiler D8. The solution is to disable it in gradle.properties by this line: android.enableD8=false

Ticket was already created here

Okio issue tracker

It is affecting almost all low cost phones excluding Samsung devices

Related