Kotlin bindings: UniFFI checksum mismatch on 32-bit ARM Android (needs uniffi >= 0.32.1)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- build-system, mobile
Direzione di ricerca
The fix is a uniffi version bump: the pin uniffi = "=0.29.4" in the workspace Cargo.toml moves to 0.32.1 or later, and the Kotlin bindings must be regenerated. Start with the generated checksum check uniffiCheckApiChecksums and the uniffi_lwk_checksum_func_derive_asset_id symbol. Done means the checksums match on an armeabi-v7a AOT build and no aarch64 checksums regress, so 0.31.2 must be avoided.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
On 32-bit ARM Android (armeabi-v7a), loading the LWK Kotlin bindings fails once the app is AOT-compiled:
java.lang.ExceptionInInitializerError
at lwk.UniffiLib.<clinit>(lwk.android.kt)
at lwk.Network$Companion.mainnet(lwk.android.kt)
Caused by: java.lang.RuntimeException: UniFFI API checksum mismatch: try cleaning and rebuilding your project
at lwk.IntegrityCheckingUniffiLib.uniffiCheckApiChecksums(lwk.android.kt:2292)
at lwk.IntegrityCheckingUniffiLib.<clinit>(lwk.android.kt:2278)
We see this in production in Blockstream Green on 32-bit Android devices installed from Google Play. The .so and the bindings match. The cause is a signedness bug in UniFFI's Kotlin bindings, fixed upstream in uniffi 0.31.2 / 0.32.1. LWK pins uniffi = "=0.29.4".
Cause
This is uniffi mozilla/uniffi-rs#2740:
- The checksum functions return Rust
u16. The generated Kotlin declares them as JNA direct-mappednative short. - On armv7, the Rust side correctly zero-extends the
u16(AAPCS), so0xF889arrives as0x0000F889. - JNA/libffi pass the register through unchanged.
- ART's compiled JNI stubs on arm32 don't re-extend small return values, so Kotlin sees 63625 instead of the expected
(short) -1911.
The interpreter path (generic JNI trampoline) sign-extends, so the bug only appears once the code is AOT-compiled, for example by Play cloud profiles or background dexopt. A plain adb install usually doesn't reproduce it. arm64 is unaffected because ART's arm64 stubs extend.
In LWK 0.19.1, 280 of the 513 checksum checks expect a negative value. The first one, uniffi_lwk_checksum_func_derive_asset_id, expects -1911, so initialization always fails. The bug is not limited to checksums: any exported function returning u8/u16 gets values ≥ 0x80/0x8000 wrong on compiled arm32 code.
Reproduction
Android 7.1.1 armeabi-v7a emulator (system-images;android-25;google_apis;armeabi-v7a, x86_64 host). The test runs with dalvikvm the lwk/IntegrityCheckingUniffiLib.class from the lwk-android 0.19.1 AAR, JNA 5.18.1, and the AAR's armeabi-v7a/liblwk.so. A small probe calls uniffi_lwk_checksum_func_derive_asset_id through JNA direct mapping.
| Run | derive_asset_id (expect -1911) |
IntegrityCheckingUniffiLib |
|---|---|---|
Interpreted (-Xnodex2oat) |
-1911 | OK |
AOT (-Xcompiler-option --compiler-filter=speed) |
63625 | checksum mismatch |
In an app: install on a 32-bit device, or with adb install --abi armeabi-v7a on a 64-bit device that supports 32-bit apps. Then run adb shell cmd package compile -m speed -f <package> and initialize LWK.
Fix
Upgrade uniffi to 0.32.1 or later:
- 0.31.2 contains the fix (mozilla/uniffi-rs#2897: Kotlin direct-mapped
u8/u16returns are widened toInt). - But 0.31.2 broke checksums on aarch64 (mozilla/uniffi-rs#2939, fixed in #2935 in 0.32.1). 0.31.2 itself should be avoided.
I'm preparing a PR with the bump.
- Lingua principale
- Rust
- Stelle
- 114
- Fork
- 69
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Blockstream/lwk
-
Ignore entry for RUSTSEC-2020-0168 no longer matches anything (`mach` is no longer in `Cargo.lock`)Forse già presa @zyl71 l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
Blockstream/lwk#213 ·
-
wollet: Waterfalls scan sets `last_unused` to a page-relative index past the first pageForse già presa @diorwave l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Blockstream/lwk#209 ·
-
C# bindings: all generated types are `internal`, `LiquidWalletKit` 0.8.2 has no usable public APIForse già presa @lisboaigor l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 25/100
Blockstream/lwk#210 ·
-
Applying a merged update with a txid in both `txid_height_new` and `txid_height_delete` drops its outputs from `unspent`Forse già presa @Jeon1691 l’ha presa 4 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 78/100
Blockstream/lwk#205 ·
-
Cache `unspent` restores an input of a deleted transaction that a known replacement still spendsAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
Blockstream/lwk#204 ·
Tutte le issue di Blockstream/lwk
Issue simili
-
Ignore entry for RUSTSEC-2026-0002 no longer matches anything (`lru` is no longer in `Cargo.lock`)Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
influxdata/influxdb#27767 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
manuscript-lang/manuscript#6389 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno