{"record":{"id":"2ce3c8a80cbba29b","repo":"pxb1988/dex2jar","slug":"encountered-restart-local-on-new-v","errorCode":null,"errorMessage":"Encountered RESTART_LOCAL on new v","messagePattern":"Encountered RESTART_LOCAL on new v","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java","lineNumber":515,"sourceCode":"                int nameIdx = readStringIndex(in);\r\n                int typeIdx = readStringIndex(in);\r\n                int sigIdx = readStringIndex(in);\r\n                String name = getString(nameIdx);\r\n                String type = getType(typeIdx);\r\n                String signature = getString(sigIdx);\r\n                DEBUG_DEBUG(\"Start: v%d :%s, %s // %s\", reg, name, type, signature);\r\n                LocalEntry le = new LocalEntry(name, type, signature);\r\n                order(labelMap, address);\r\n                dcv.visitStartLocal(reg, labelMap.get(address), name, type, signature);\r\n                lastEntryForReg[reg] = le;\r\n            }\r\n                break;\r\n\r\n            case DBG_RESTART_LOCAL: {\r\n                int reg = readULeb128i(in);\r\n                LocalEntry le = lastEntryForReg[reg];\r\n                if (le == null) {\r\n                    throw new RuntimeException(\"Encountered RESTART_LOCAL on new v\" + reg);\r\n                }\r\n                if (le.signature == null) {\r\n                    DEBUG_DEBUG(\"Start: v%d :%s, %s\", reg, le.name, le.type);\r\n                } else {\r\n                    DEBUG_DEBUG(\"Start: v%d :%s, %s // %s\", reg, le.name, le.type, le.signature);\r\n                }\r\n                order(labelMap, address);\r\n                dcv.visitRestartLocal(reg, labelMap.get(address));\r\n            }\r\n                break;\r\n\r\n            case DBG_END_LOCAL: {\r\n                int reg = readULeb128i(in);\r\n                LocalEntry le = lastEntryForReg[reg];\r\n                if (le == null) {\r\n                    throw new RuntimeException(\"Encountered RESTART_LOCAL on new v\" + reg);\r\n                }\r\n                if (le.signature == null) {\r","sourceCodeStart":497,"sourceCodeEnd":533,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-reader/src/main/java/com/googlecode/d2j/reader/DexFileReader.java#L497-L533","documentation":"While decoding the debug_info_item state machine, a DBG_RESTART_LOCAL opcode refers to a register that has no previous 'start local' entry in lastEntryForReg. The reader cannot 'restart' a local that was never started, so it throws a RuntimeException naming the offending register. This indicates a malformed or non-standard debug section.","triggerScenarios":"Processing dex bytecode whose debug info contains DBG_RESTART_LOCAL for a register with no prior DBG_START_LOCAL/DBG_START_LOCAL_EXTENDED — typically a corrupted debug_info_item or output from a non-conforming dex compiler/obfuscator.","commonSituations":"Reading dex files produced by aggressive obfuscators that strip or rewrite debug info; hand-patched dex; tools like dex2jar converting dex with broken debug state during translate/debug reads.","solutions":["Recompile/re-dex the source with d8/dx to regenerate valid debug info","Strip debug info (d8 --no-debug-info or dx --no-debug-info / --no-local-info) so the debug state machine is never walked","Patch the dex's debug_info_item so every DBG_RESTART_LOCAL follows a matching start for that register","As a last resort, patch the library to log-and-skip instead of throwing if you accept losing that local's info"],"exampleFix":"// before\n// dx --debug classes.jar  # keeps fragile debug info\n// after\n// dx --no-local-info --output classes.dex classes.jar","handlingStrategy":"validation","validationCode":"// Prefer pre-validating the toolchain output:\n// d8 --release --no-debug-info avoids DBG_RESTART_LOCAL processing entirely.\n// There is no cheap pre-check for debug-info consistency; strip debug info instead:\n// Process.run(\"d8\", \"--release\", \"--no-debug-info\", \"--output\", outDir, input)\nnull","typeGuard":null,"tryCatchPattern":"try {\n    new DexFileReader(file).accept(visitor);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Encountered RESTART_LOCAL\")) {\n        // fall back to a no-debug-info build of the same dex\n        return parseWithDebugInfoStripped(file);\n    }\n    throw e;\n}","preventionTips":["Strip local/debug info with --no-debug-info / --no-local-info when the source dex comes from untrusted toolchains","Re-dex obfuscated artifacts rather than parsing their debug sections","Keep dex-lib updated; newer builds are more tolerant of odd debug streams"],"tags":["dex","debug-info","malformed-input"],"backgroundTag":"internal-invariant-violation","analyzedSha":"b5bda4fb4935ae8b3869b422454ae3b3896c7bc1","analyzedAt":"2026-09-08T00:44:01.258Z","contentChangedAt":"2026-09-08T00:44:01.258Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}