Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException crash from SDK when DP3T.sendIAmInfected() is called #173

Closed
harri35 opened this issue Jul 9, 2020 · 5 comments

Comments

@harri35
Copy link

harri35 commented Jul 9, 2020

ArrayIndexOutOfBoundsException crash from SDK when DP3T.sendIAmInfected() is called.
SDK: DP-3T SDK 1.0.0
GAEN: v1.3.1

I have an Android DP-3T related crash I am getting intermittently.

I do a clean install of our app. It uses the 1.0.0 DP-3T SDK and play-services-nearby-18.0.2-eap-v1.3.1.aar
I give all the permissions and GAEN works on this device. After our onboarding flow GAEN activates (Settings -> Google -> COVID-19 submenu also confirms this)

Immediately after install, I start our infection confirmation flow. In the flow as a user, I enter the onsetDate as today's date.
After our app has confirmed with our backend that I am allowed to confirm my infection then our app calls the DP-3T SDK:

DP3T.sendIAmInfected(activity, onsetDate, ...

DP-3T SDK crashes with

java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at com.google.gson.internal.$Gson$Types.getGenericSupertype($Gson$Types.java:248)
at com.google.gson.internal.$Gson$Types.getSupertype($Gson$Types.java:284)
at com.google.gson.internal.$Gson$Types.getCollectionElementType($Gson$Types.java:302)
at com.google.gson.internal.bind.CollectionTypeAdapterFactory.create(CollectionTypeAdapterFactory.java:52)
at com.google.gson.Gson.getAdapter(Gson.java:458)
at com.google.gson.Gson.fromJson(Gson.java:926)
at com.google.gson.Gson.fromJson(Gson.java:892)
at com.google.gson.Gson.fromJson(Gson.java:841)
at com.google.gson.Gson.fromJson(Gson.java:813)
at org.dpppt.android.sdk.internal.util.Json.fromJson(Json.java:34)
at org.dpppt.android.sdk.internal.PendingKeyUploadStorage.getPendingKeys(PendingKeyUploadStorage.java:53)
at org.dpppt.android.sdk.internal.PendingKeyUploadStorage.addPendingKey(PendingKeyUploadStorage.java:85)
at org.dpppt.android.sdk.DP3T$1.onSuccess(DP3T.java:277)
at org.dpppt.android.sdk.DP3T$1.onSuccess(DP3T.java:269)
at org.dpppt.android.sdk.internal.backend.BackendReportRepository$1.onResponse(BackendReportRepository.java:54)
at retrofit2.DefaultCallAdapterFactory$ExecutorCallbackCall$1.lambda$onResponse$0$DefaultCallAdapterFactory$ExecutorCallbackCall$1(DefaultCallAdapterFactory.java:89)
at retrofit2.-$$Lambda$DefaultCallAdapterFactory$ExecutorCallbackCall$1$3wC8FyV4pyjrzrYL5U0mlYiviZw.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

from the line PendingKeyUploadStorage.getInstance(activity).addPendingKey(delayedKey); inside the public void onSuccess(String authToken) callback.
As nobody will catch the Exception then our whole app also crashes.

So IMHO two issues here:

  1. The crash itself
  2. That the code running in the callback should also handle unexpected errors better and not crash the app, but just give a failure callback to the app.
@fbzli
Copy link
Contributor

fbzli commented Jul 9, 2020

Any chance you have Proguard enabled? I can only reproduce this with obfuscation enabled specifically.

The PendingKey model appears to be in the wrong package/class, thus is not protected by the proguard exemption rules. We're going to fix that.

@harri35
Copy link
Author

harri35 commented Jul 10, 2020

Hei!
The SDK we use is built by us, but it has
minifyEnabled false
for now

Same with our application. We are planning to use Proguard or R8 for our release, but this has not been correctly configured yet.

I am trying to reproduce this today myself, and have no luck thus far.

@fbzli
Copy link
Contributor

fbzli commented Jul 10, 2020

Correction: I can also reproduce this with a release (not debug) build using coreLibraryDesugaringEnabled true , and Proguard disabled.

@harri35
Copy link
Author

harri35 commented Jul 10, 2020

  1. I tested with a release build with Proguard enabled - I can reproduce it this way easily, you are correct.

  2. We do have "coreLibraryDesugaringEnabled true" on both debug and release.
    When I turn off Proguard / R8 by
    shrinkResources false setMinifyEnabled false
    then I can reproduce it also. But only on release.

Btw, we are using com.android.tools:desugar_jdk_libs:1.0.9

  1. Debug still fine, like you said, can't reproduce it there.

I am starting to doubt myself now. Maybe I was on release then. Sorry about that.

@fbzli
Copy link
Contributor

fbzli commented Jul 10, 2020

I pushed a fix. That should work with any Proguard configuration and/or core library desugaring enabled.

@fbzli fbzli closed this as completed Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants