internal dex lib: const-string not widened to /jumbo when dex has >65535 strings (Short value out of range; jf handles it)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- build-system
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Java
- Star
- 2.3k
- Fork
- 417
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của REAndroid/APKEditor
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Tất cả issue của REAndroid/APKEditor
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jenkins-infra/plugin-modernizer-tool#2070 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Event search answers 500 when calendars, attendees or organizers holds a null elementCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởai-driven-qa bug Minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
linagora/twake-calendar-side-service#1615 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
eclipse-tradista/tradista#371 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Failed to start Rescue missionĐang mởcritical
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
mars-sim/mars-sim#2199 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày