internal dex lib: const-string not widened to /jumbo when dex has >65535 strings (Short value out of range; jf handles it)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- build-system
Direzione di ricerca
The exception is raised from SizeXIns.setShort at SizeXIns.java:99 in the com.reandroid.dex.ins package, reached while building a const-string (21c) whose string index exceeds 0xffff. Start there, then look at where const-string instructions are chosen or encoded and at how the existing const-string/jumbo (31c) path is written. Reproduce with a dex holding more than 65535 strings and one added const-string. Done means such an instruction is widened to const-string/jumbo, branch offsets are relaid out, and the rebuilt dex reads cleanly.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
Regression from V1.4.1 to V1.4.9: when a dex already has more than 65535 strings, adding a class or a string to it makes b fail on a plain const-string. V1.4.1 builds the same input fine: it widened the affected const-string to const-string/jumbo automatically. V1.4.9 throws instead:
com.reandroid.dex.ins.InstructionException: Short value out of range 0x1253f > 0xffff, dex = classes3.dex, class = Lcom/android/systemui/kashi/NotificationRedClockHelper$3;, method = ... { ... const-string ... }
at com.reandroid.dex.ins.SizeXIns.setShort(SizeXIns.java:99)
This is not about the dex being out of space. A dex can hold far more than 65535 strings (the one below ends up with 75477), and const-string/jumbo exists for exactly this case. Strings are sorted, so adding new ones shifts the index of existing ones. A const-string that fit at decompile time can end up past 0xffff, and the smali author has no way to know that ahead of time.
Same root cause as #236 (closed without a fix) and probably #231.
To Reproduce
- Used version: V1.4.9 (official release jar). Works with V1.4.1.
- Operating system: Linux (also seen on GitHub Actions ubuntu runners)
- Commands:
# any apk with a dex past 65535 strings (here MIUI SystemUI, classes3.dex = ~75K strings;
# its smali already contains ~3900 const-string/jumbo)
java -jar APKEditor.jar d -t raw -i SystemUI.apk -o out -f
# add any new class with a few new strings to that dex
cp NewHelper.smali out/smali/classes3/com/example/
java -jar APKEditor.jar b -t raw -i out -o rebuilt.apk -f
Rebuilding without changes works with both versions, because the dex is cached. With the added class:
| version | result |
|---|---|
| V1.4.1 | builds. Output classes3.dex has 3950 const-string/jumbo (source smali: 3906), and dexdump reads it cleanly |
| V1.4.9 | InstructionException: Short value out of range ... const-string |
Expected
As in V1.4.1 (and like d8 does): when a const-string (21c) has a string index above 0xffff, encode it as const-string/jumbo (31c) instead of throwing, then re-layout branch offsets as for any instruction size change.
Workaround
Rewrite every const-string in the affected dex's smali as const-string/jumbo before building. This builds fine with V1.4.9, which shows the writer itself handles jumbo correctly. Only the automatic widening is missing.
- Lingua principale
- Java
- Stelle
- 2.3k
- Fork
- 417
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
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 REAndroid/APKEditor
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Tutte le issue di REAndroid/APKEditor
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
seleniumboot/selenium-boot#275 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
jenkins-infra/plugin-modernizer-tool#2070 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
orientechnologies/orientdb#11020 ·
I maintainer di solito rispondono entro 1 giorno
-
Event search answers 500 when calendars, attendees or organizers holds a null elementForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaai-driven-qa bug Minor
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
linagora/twake-calendar-side-service#1615 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno