golang/go · error

subprogram DIE has no high_pc attr

Error message

subprogram DIE has no high_pc attr

What it means

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.

Source

Thrown at src/cmd/link/internal/dwtest/dwtest.go:229

		err = fmt.Errorf("subprogram DIE has no low_pc attr")
		return
	}
	if lofield.Class != dwarf.ClassAddress {
		err = fmt.Errorf("subprogram DIE low_pc attr is not of class address")
		return
	}
	if lopc, ok := lofield.Val.(uint64); ok {
		lo = lopc
	} else {
		err = fmt.Errorf("subprogram DIE low_pc not convertible to uint64")
		return
	}

	// For the high_pc value, we'll accept either an address or a constant
	// offset from lo pc.
	hifield := subprogdie.AttrField(dwarf.AttrHighpc)
	if hifield == nil {
		err = fmt.Errorf("subprogram DIE has no high_pc attr")
		return
	}
	switch hifield.Class {
	case dwarf.ClassAddress:
		if hipc, ok := hifield.Val.(uint64); ok {
			hi = hipc
		} else {
			err = fmt.Errorf("subprogram DIE high not convertible to uint64")
			return
		}
	case dwarf.ClassConstant:
		if hioff, ok := hifield.Val.(int64); ok {
			hi = lo + uint64(hioff)
		} else {
			err = fmt.Errorf("subprogram DIE high_pc not convertible to uint64")
			return
		}
	default:

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Check subprogdie.AttrField(dwarf.AttrHighpc) != nil before calling the helper, skipping DIEs without it.
  2. Filter out declarations (DW_AT_declaration) and abstract origins that legitimately lack high_pc.
  3. If the function should have a body, investigate the linker's DIE emission for the missing attribute.

Example fix

// before
for _, d := range subprograms {
    lo, hi, err := dwtest.SubprogLoAndHighPc(d)
}
// after
for _, d := range subprograms {
    if d.AttrField(dwarf.AttrLowpc) == nil || d.AttrField(dwarf.AttrHighpc) == nil {
        continue
    }
    lo, hi, err := dwtest.SubprogLoAndHighPc(d)
}
Defensive patterns

Strategy: validation

Validate before calling

if subprogdie.AttrField(dwarf.AttrHighpc) == nil {
    // no high_pc — cannot compute range; skip
    return 0, 0, nil
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/58b8ffdb69f1806a. Report an issue: GitHub.