{"record":{"id":"7ae4e938f75902cd","repo":"Tencent/tinker","slug":"bogus-element-width","errorCode":null,"errorMessage":"bogus element_width: {}","messagePattern":"bogus element_width: (.+?)","errorType":"exception","errorClass":"DexException","httpStatus":null,"severity":"error","filePath":"third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dx/instruction/InstructionPromoter.java","lineNumber":520,"sourceCode":"            case 1: {\n                int length = ((byte[]) data).length;\n                this.currentPromotedAddress += (length >> 1) + (length & 1);\n                break;\n            }\n            case 2: {\n                this.currentPromotedAddress += ((short[]) data).length * 1;\n                break;\n            }\n            case 4: {\n                this.currentPromotedAddress += ((int[]) data).length * 2;\n                break;\n            }\n            case 8: {\n                this.currentPromotedAddress += ((long[]) data).length * 4;\n                break;\n            }\n            default: {\n                throw new DexException(\"bogus element_width: \" + Hex.u2(elementWidth));\n            }\n        }\n    }\n}\n","sourceCodeStart":502,"sourceCodeEnd":525,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dx/instruction/InstructionPromoter.java#L502-L525","documentation":"InstructionPromoter rewrites 16-bit dex instructions into their wide-index (jumbo/promoted) forms while recomputing the promoted instruction address. Each instruction's code-unit width is derived from the backing array type (short[] = 1 unit per element, int[] = 2, long[] = 4); the switch's default branch fires when elementWidth is none of the handled values, i.e. an instruction format this promoter version does not know. The message is an internal invariant violation, not a normal data error.","triggerScenarios":"Promoting instructions (used when tinker rebuilds a dex with a promoter attached, typically to upgrade const-string to const-string/jumbo) and encountering an instruction whose element width is not 2, 4, or 8 — e.g. an opcode/format introduced by a newer dex spec or emitted by an exotic compiler.","commonSituations":"Parsing dex files produced by new AGP/d8 versions after an old aosp-dexutils was pinned; custom bytecode injected by an agent/framework using an instruction format the vendored dx code predates; version skew between the tool that built the dex and the vendored third-party/aosp-dexutils.","solutions":["Upgrade the tinker dependency (which vendors aosp-dexutils) to a release whose dx instruction tables cover the dex format you are processing.","Reproduce with a minimal dex and capture the opcode/format at the failure point (log elementWidth and the instruction) to confirm it is an unknown-format gap rather than corrupt input.","If the input dex may simply be corrupt, validate it first with dexdump; a corrupt instruction stream can also yield an unhandled width.","If the gap is confirmed, file an issue with the tinker project including the failing dex so the promoter's width table is extended."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Smoke-test the dex with dexdump before promoting instructions\nboolean dexParsesCleanly(java.io.File dexFile) {\n    try {\n        Process p = new ProcessBuilder(\"dexdump\", dexFile.getAbsolutePath()).start();\n        return p.waitFor() == 0;\n    } catch (Exception e) {\n        return false;\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    promoter.visit(instruction);\n} catch (com.tencent.tinker.android.dex.DexException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"bogus element_width\")) {\n        // unsupported instruction format: report dex + toolchain versions, abort this build\n        throw new UnsupportedOperationException(\"unsupported dex instruction format; upgrade tinker/aosp-dexutils\", e);\n    }\n    throw e;\n}","preventionTips":["Pin consistent versions between the dex-producing toolchain and tinker's vendored aosp-dexutils.","Validate new dex formats with dexdump before feeding them to the promoter.","Log the opcode/format at promotion time so unknown-format gaps are diagnosable from the first failure."],"tags":["dex","instruction-promoter","invariant","tinker"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}