internal dex lib: const-string not widened to /jumbo when dex has >65535 strings (Short value out of range; jf handles it)
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 领域
- build-system
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Java
- 星标
- 2.3k
- 派生
- 417
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
REAndroid/APKEditor 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 67/100
-
bug
难度 4/5 3-5 天 新手友好度 38/100
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
-
enhancement
难度 3/5 1-2 天 新手友好度 45/100
-
bug
难度 4/5 3-5 天 新手友好度 35/100
查看 REAndroid/APKEditor 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
good first issue
难度 2/5 1-3 小时 新手友好度 78/100
seleniumboot/selenium-boot#275 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
jenkins-infra/plugin-modernizer-tool#2070 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 84/100
orientechnologies/orientdb#11020 ·
维护者通常 1 天内回复
-
Event search answers 500 when calendars, attendees or organizers holds a null element可能重新可做 关联的 PR 已关闭且未合并。 未关闭ai-driven-qa bug Minor
难度 2/5 1-3 小时 新手友好度 70/100
linagora/twake-calendar-side-service#1615 · 1 条评论 ·
维护者通常 1 天内回复