{"record":{"id":"676df23edb961e12","repo":"go-delve/delve","slug":"could-not-read-from-instruction-buffer","errorCode":null,"errorMessage":"Could not read from instruction buffer","messagePattern":"Could not read from instruction buffer","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/dwarf/frame/table.go","lineNumber":205,"sourceCode":"\tframe.buf.Truncate(0)\n\tframe.buf.Write(instructions)\n\n\t// We only need to execute the instructions until\n\t// ctx.loc > ctx.address (which is the address we\n\t// are currently at in the traced process).\n\tfor frame.address >= frame.loc && frame.buf.Len() > 0 && frame.err == nil {\n\t\texecuteDwarfInstruction(frame)\n\t}\n\treturn frame.err\n}\n\nfunc executeDwarfInstruction(frame *FrameContext) {\n\tif frame.err != nil {\n\t\treturn\n\t}\n\tinstruction, err := frame.buf.ReadByte()\n\tif err != nil {\n\t\tpanic(\"Could not read from instruction buffer\")\n\t}\n\n\tif instruction == DW_CFA_nop {\n\t\treturn\n\t}\n\n\tfn := lookupFunc(instruction, frame.buf)\n\n\tif fn == nil {\n\t\tframe.err = fmt.Errorf(\"encountered an unexpected DWARF CFA opcode: %#v\", instruction)\n\t\treturn\n\t}\n\n\tfn(frame)\n}\n\nfunc lookupFunc(instruction byte, buf *bytes.Buffer) instruction {\n\tconst high_2_bits = 0xc0","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/dwarf/frame/table.go#L187-L223","documentation":"executeDwarfInstruction panics when the DWARF CFI instruction buffer is exhausted mid-decode: buf.ReadByte() failed so there is no opcode byte to dispatch on. This indicates a truncated or malformed .eh_frame/.debug_frame section (or a decode offset bug), and the library surfaces it as a panic rather than an error return.","triggerScenarios":"Parsing a frame description entry whose CIE/FDE length fields are inconsistent with the actual section data; a corrupt or hand-trimmed binary; a truncated core dump or stripped binary where the frame section was cut short.","commonSituations":"Analyzing core dumps from mismatched or partially written files; binaries produced by non-Go toolchains or linkers that emit unusual FDE padding; loading symbols from a binary corrupted during download/transfer.","solutions":["Regenerate or re-obtain the binary/core file and retry — corruption is the usual cause","Verify the executable and core dump come from the same build and are complete (checksums)","File a bug with the offending binary attached: a panic here is a parser robustness defect and should be recovered/converted to an error upstream","As a caller, wrap ExecuteUntilPC in a recover() until the parser is hardened"],"exampleFix":"// caller-side mitigation\n// before\nfde, err := table.ExecuteUntilPC(pc)\n// after\nfunc safeExecute(t *frame.Table, pc uint64) (res *frame.FrameDescriptionEntry, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"malformed frame data: %v\", r)\n        }\n    }()\n    return t.ExecuteUntilPC(pc)\n}","handlingStrategy":"try-catch","validationCode":"// Verify inputs before parsing frame data:\n// 1) binary and core exist and are non-empty\nfi, err := os.Stat(corePath)\nif err != nil || fi.Size() == 0 { return fmt.Errorf(\"missing/empty core file\") }\n// 2) match ELF build IDs between executable and core\n// (mismatches commonly produce truncated/misread DWARF sections)","typeGuard":null,"tryCatchPattern":"func safeExecute(t *frame.Table, pc uint64) (res *frame.FrameDescriptionEntry, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"malformed CFI stream: %v\", r)\n        }\n    }()\n    return t.ExecuteUntilPC(pc)\n}","preventionTips":["Always pair core dumps with the exact matching executable build","Validate downloaded binaries (checksum/build ID) before analysis","Wrap pkg/dwarf/frame entry points in recover() — they panic on malformed input","Report panics with the offending binary to delve maintainers"],"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"}