Skip to content

fix: resolve #1195 — 【Update@2019-12-18】ART内联或AOT导致VerifyError及其他类型的闪退#1790

Open
Nam0101 wants to merge 3 commits into
Tencent:devfrom
Nam0101:contribai/improve/quality/add-explicit-alignment-helper-and-use-it
Open

fix: resolve #1195 — 【Update@2019-12-18】ART内联或AOT导致VerifyError及其他类型的闪退#1790
Nam0101 wants to merge 3 commits into
Tencent:devfrom
Nam0101:contribai/improve/quality/add-explicit-alignment-helper-and-use-it

Conversation

@Nam0101
Copy link
Copy Markdown

@Nam0101 Nam0101 commented May 16, 2026

Summary

fix: resolve #1195 — 【Update@2019-12-18】ART内联或AOT导致VerifyError及其他类型的闪退

Problem

Severity: High | File: third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/io/DexDataBuffer.java

DexDataBuffer is the low-level writer used by all section serializers in DexDiff/DexPatch. If any caller forgets to call alignment before writing an aligned section (specifically after variable-length encoded sections like ClassDataItem, EncodedArrayItem, AnnotationItem), the resulting dex layout has misaligned offsets which Android P's verifier rejects.

Solution

Add a robust alignToFourBytesWithZeroFill() method (or verify it exists and is correct, padding with 0x00). Audit all callers in Dex.java, DexWriter, and the various section visitors (ClassDataItem, AnnotationsDirectory, Code, TypeList, AnnotationSet, AnnotationSetRefList) to make sure they invoke alignment before writing each new section. Add an assertion in section-finalization paths comparing actual position() to the expected aligned offset stored in TableOfContents.

Changes

  • third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/io/DexDataBuffer.java (modified)
  • tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/loader/SystemClassLoaderAdder.java (new)
  • third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/Dex.java (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

Note: this change was drafted with AI assistance and reviewed locally before submission.

Nam0101 added 3 commits May 17, 2026 04:06
…及其他类型的闪退

Fixes Tencent#1195

Signed-off-by: Nguyen Van Nam <nam.nv205106@gmail.com>
…及其他类型的闪退

Fixes Tencent#1195

Signed-off-by: Nguyen Van Nam <nam.nv205106@gmail.com>
…及其他类型的闪退

Fixes Tencent#1195

Signed-off-by: Nguyen Van Nam <nam.nv205106@gmail.com>
@tencent-adm
Copy link
Copy Markdown
Member

tencent-adm commented May 16, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

【Update@2019-12-18】ART内联或AOT导致VerifyError及其他类型的闪退

2 participants