{"record":{"id":"486ded9fbcafeef8","repo":"go-delve/delve","slug":"could-not-read-byte","errorCode":null,"errorMessage":"Could not read byte","messagePattern":"Could not read byte","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/dwarf/frame/table.go","lineNumber":255,"sourceCode":"\t\tinstruction = DW_CFA_restore\n\t\trestore = true\n\t}\n\n\tif restore {\n\t\t// Restore the last byte as it actually contains the argument for the opcode.\n\t\terr := buf.UnreadByte()\n\t\tif err != nil {\n\t\t\tpanic(\"Could not unread byte\")\n\t\t}\n\t}\n\n\treturn fnlookup[instruction]\n}\n\nfunc advanceloc(frame *FrameContext) {\n\tb, err := frame.buf.ReadByte()\n\tif err != nil {\n\t\tpanic(\"Could not read byte\")\n\t}\n\n\tdelta := b & low_6_offset\n\tframe.loc += uint64(delta) * frame.codeAlignment\n}\n\nfunc advanceloc1(frame *FrameContext) {\n\tdelta, err := frame.buf.ReadByte()\n\tif err != nil {\n\t\tpanic(\"Could not read byte\")\n\t}\n\n\tframe.loc += uint64(delta) * frame.codeAlignment\n}\n\nfunc advanceloc2(frame *FrameContext) {\n\tvar delta uint16\n\tbinary.Read(frame.buf, frame.order, &delta)","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/dwarf/frame/table.go#L237-L273","documentation":"advanceloc panics when it cannot read the delta byte for a DW_CFA_advance_loc1-style one-byte location advance. The frame instruction stream ended exactly where an operand byte was expected, meaning the CFI program is truncated relative to its declared length.","triggerScenarios":"Parsing a frame description entry whose declared length extends past the end of the section data; corrupted .debug_frame/.eh_frame sections; decode bugs where buf was not rewound between CFI programs.","commonSituations":"Analyzing a truncated or partially downloaded binary; core dump files whose mapped frame sections are incomplete; third-party binaries with hand-written assembler frames.","solutions":["Verify the binary/core integrity and re-acquire it from a trusted source","Check that the binary and core dump match (same build ID)","Report to delve maintainers — this should be an error return, not a panic","Recover from the panic at the call site and skip frame unwinding for that frame"],"exampleFix":"// before\nframes, err := t.ExecuteUntilPC(pc) // panic on malformed stream\n// after\nfunc safeFrames(t *frame.Table, pc uint64) (frames []frame.Frame, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"invalid CFI stream: %v\", r)\n        }\n    }()\n    fde, e := t.ExecuteUntilPC(pc)\n    if e != nil {\n        return nil, e\n    }\n    frames, err = fde.EstablishFrame(t.CIE) // illustrative decode\n    return\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"func safeAdvance(t *frame.FrameDescriptionEntry) (err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"truncated CFI stream: %v\", r)\n        }\n    }()\n    // trigger the decode path\n    return nil\n}","preventionTips":["Verify section integrity (SHT sizes vs declared FDE lengths) when pre-processing binaries","Ensure core files are fully flushed/complete before analysis","Recover around frame decoding and degrade gracefully (partial stack)","Keep delve updated; parser hardening fixes land over time"],"tags":["dwarf","panic","frame-parsing"],"backgroundTag":"malformed-dwarf-data","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}