{"record":{"id":"a8bfd8fd6f6b0dd0","repo":"go-delve/delve","slug":"panic-err-a8bfd8","errorCode":null,"errorMessage":"panic(err)","messagePattern":"panic\\(err\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/dwarf/line/state_machine.go","lineNumber":526,"sourceCode":"\tsm.address += uint64((255-sm.dbl.Prologue.OpcodeBase)/sm.dbl.Prologue.LineRange) * uint64(sm.dbl.Prologue.MinInstrLength)\n}\n\nfunc fixedadvancepc(sm *StateMachine, buf *bytes.Buffer) {\n\tvar operand uint16\n\tbinary.Read(buf, binary.LittleEndian, &operand)\n\n\tsm.address += uint64(operand)\n}\n\nfunc endsequence(sm *StateMachine, buf *bytes.Buffer) {\n\tsm.endSeq = true\n\tsm.valid = sm.dbl.endSeqIsValid\n}\n\nfunc setaddress(sm *StateMachine, buf *bytes.Buffer) {\n\taddr, err := dwarf.ReadUintRaw(buf, binary.LittleEndian, sm.ptrSize)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tsm.address = addr + sm.dbl.staticBase\n}\n\nfunc setdiscriminator(sm *StateMachine, buf *bytes.Buffer) {\n\t_, _ = leb128.DecodeUnsigned(buf)\n}\n\nfunc definefile(sm *StateMachine, buf *bytes.Buffer) {\n\tif entry := readFileEntry(sm.dbl, sm.buf, false); entry != nil {\n\t\tsm.definedFiles = append(sm.definedFiles, entry)\n\t}\n}\n\nfunc prologueend(sm *StateMachine, buf *bytes.Buffer) {\n\tsm.prologueEnd = true\n}\n","sourceCodeStart":508,"sourceCodeEnd":544,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/dwarf/line/state_machine.go#L508-L544","documentation":"The DWARF line-table state machine's `setaddress` (DW_LNS_set_address extended opcode) handler panics with the raw io error when dwarf.ReadUintRaw cannot read ptrSize bytes from the line program buffer. This indicates the .debug_line section is truncated or the state machine is reading past the end of the program. The library assumes well-formed line data and treats EOF as fatal.","triggerScenarios":"Processing a DW_LNS_set_address opcode whose following address bytes extend beyond the buffer end — truncated .debug_line section, incorrect prologue_length/unit_length handling, or corrupted line program data.","commonSituations":"Stripped or damaged binaries and core dumps; toolchain-produced line tables with inconsistent unit lengths; manual slicing of the line program buffer with wrong boundaries.","solutions":["Verify the binary/core's .debug_line section is complete (unit_length bounds the program).","Check how the buffer for this line program unit was sliced — a wrong unit_length leads to premature EOF.","Update Delve; newer versions may report a line-table parse error instead of panicking.","Recover() around line-table parsing when handling untrusted or third-party binaries."],"exampleFix":"// before\naddr, err := dwarf.ReadUintRaw(buf, binary.LittleEndian, sm.ptrSize)\nif err != nil {\n\tpanic(err)\n}\n// after\naddr, err := dwarf.ReadUintRaw(buf, binary.LittleEndian, sm.ptrSize)\nif err != nil {\n\treturn nil, fmt.Errorf(\"truncated .debug_line: set_address: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// Go: ensure the line program buffer is at least unit_length bytes\nif uint64(len(lineProg)) < unitLength {\n\treturn errors.New(\"truncated .debug_line program\")\n}","typeGuard":null,"tryCatchPattern":"// Go\ngo func() {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = fmt.Errorf(\"line-table parse failed: %v\", r)\n\t\t}\n\t}()\n\tsm.Run() // state machine over line program\n}()","preventionTips":["Verify .debug_line unit_length bounds before running the state machine","Avoid slicing line-program buffers with hand-computed lengths","Use intact binaries/cores (re-dump corrupted cores)","Recover() when parsing third-party or fuzzed binaries"],"tags":["dwarf","line-table","panic","truncated-data"],"backgroundTag":"malformed-dwarf-data","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}