{"record":{"id":"58b8ffdb69f1806a","repo":"golang/go","slug":"subprogram-die-has-no-high-pc-attr","errorCode":null,"errorMessage":"subprogram DIE has no high_pc attr","messagePattern":"subprogram DIE has no high_pc attr","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/link/internal/dwtest/dwtest.go","lineNumber":229,"sourceCode":"\t\terr = fmt.Errorf(\"subprogram DIE has no low_pc attr\")\n\t\treturn\n\t}\n\tif lofield.Class != dwarf.ClassAddress {\n\t\terr = fmt.Errorf(\"subprogram DIE low_pc attr is not of class address\")\n\t\treturn\n\t}\n\tif lopc, ok := lofield.Val.(uint64); ok {\n\t\tlo = lopc\n\t} else {\n\t\terr = fmt.Errorf(\"subprogram DIE low_pc not convertible to uint64\")\n\t\treturn\n\t}\n\n\t// For the high_pc value, we'll accept either an address or a constant\n\t// offset from lo pc.\n\thifield := subprogdie.AttrField(dwarf.AttrHighpc)\n\tif hifield == nil {\n\t\terr = fmt.Errorf(\"subprogram DIE has no high_pc attr\")\n\t\treturn\n\t}\n\tswitch hifield.Class {\n\tcase dwarf.ClassAddress:\n\t\tif hipc, ok := hifield.Val.(uint64); ok {\n\t\t\thi = hipc\n\t\t} else {\n\t\t\terr = fmt.Errorf(\"subprogram DIE high not convertible to uint64\")\n\t\t\treturn\n\t\t}\n\tcase dwarf.ClassConstant:\n\t\tif hioff, ok := hifield.Val.(int64); ok {\n\t\t\thi = lo + uint64(hioff)\n\t\t} else {\n\t\t\terr = fmt.Errorf(\"subprogram DIE high_pc not convertible to uint64\")\n\t\t\treturn\n\t\t}\n\tdefault:","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/link/internal/dwtest/dwtest.go#L211-L247","documentation":"Thrown by SubprogLoAndHighPc (dwtest.go:227-231) when a subprogram DIE has no DW_AT_high_pc attribute (AttrField returns nil). Without high_pc the code range cannot be computed, so the helper errors. The function accepts high_pc as either ClassAddress or ClassConstant (DWARF4 offset style), but the attribute must be present.","triggerScenarios":"Calling SubprogLoAndHighPc on a subprogram DIE that has low_pc but omitted high_pc; a declaration-only or external DIE; a linker bug that dropped high_pc during optimization.","commonSituations":"DIE is a declaration/abstract origin without a range; split DWARF where high_pc resides elsewhere; dead-code elimination removed the range but left low_pc.","solutions":["Check subprogdie.AttrField(dwarf.AttrHighpc) != nil before calling the helper, skipping DIEs without it.","Filter out declarations (DW_AT_declaration) and abstract origins that legitimately lack high_pc.","If the function should have a body, investigate the linker's DIE emission for the missing attribute."],"exampleFix":"// before\nfor _, d := range subprograms {\n    lo, hi, err := dwtest.SubprogLoAndHighPc(d)\n}\n// after\nfor _, d := range subprograms {\n    if d.AttrField(dwarf.AttrLowpc) == nil || d.AttrField(dwarf.AttrHighpc) == nil {\n        continue\n    }\n    lo, hi, err := dwtest.SubprogLoAndHighPc(d)\n}","handlingStrategy":"validation","validationCode":"if subprogdie.AttrField(dwarf.AttrHighpc) == nil {\n    // no high_pc — cannot compute range; skip\n    return 0, 0, nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-check both AttrLowpc and AttrHighpc presence before calling SubprogLoAndHighPc.","Skip declaration/abstract-origin DIEs that legitimately omit high_pc."],"tags":["dwarf","go-linker","dwtest","debug-info"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}