The Android demo (open-ecard-android) demonstrates a deadlock in Android-lib
Disclaimer: This problem is limited to the Android-specific libraries.
A reproducible deadlock arises between the main activity thread (aka the UI thread), and a worker thread dedicated to the authentication process.
Steps to reproduce:¶
The problem arises when the Android activity lifecycle stops the activity, triggering a cancellation of the authentication process. This cancellation process will wait for the worker thread to terminate.
However, the interrupt currently causes the worker thread to handle/notify the user of the process interruption and thus the worker thread requests for the cancellation dialogue from the UI thread, as seen here:
FutureTask<Dialog> t = new FutureTask(this::showCardRemoveDialog); parent.runOnUiThread(t);
Because the UI thread is stuck in the join, it will never execute the code in the FutureTask and both threads deadlock.
Updated by Neil Crossley about 2 years ago
Permalinks of the quoted code:
- The UI joining with the worker: https://github.com/ecsec/open-ecard/blob/e64cf787b08aefa5cff08fa6bcdecb86493984dd/clients/android-lib/src/main/java/org/openecard/android/activation/AbstractActivationHandler.java#L367