internal dex lib: const-string not widened to /jumbo when dex has >65535 strings (Short value out of range; jf handles it)
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- build-system
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Java
- Estrellas
- 2.3k
- Forks
- 417
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de REAndroid/APKEditor
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
-
enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
Todos los issues de REAndroid/APKEditor
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
jenkins-infra/plugin-modernizer-tool#2070 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Event search answers 500 when calendars, attendees or organizers holds a null elementQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertoai-driven-qa bug Minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
linagora/twake-calendar-side-service#1615 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
eclipse-tradista/tradista#371 ·
Los mantenedores suelen responder en 1 día
-
Failed to start Rescue missionAbiertocritical
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
mars-sim/mars-sim#2199 · 2 comentarios ·
Los mantenedores suelen responder en 1 día