golang/go · error

dwarf: null reference in %d

Error message

dwarf: null reference in %d

What it means

Returned by putattr when handling DW_FORM_ref_addr or DW_FORM_sec_offset with a nil `data` argument. These forms emit an offset into another DWARF section via ctxt.AddDWARFAddrSectionOffset(s, data, value); a nil data means there is no referenced section, which the DWARF emitter treats as a hard error rather than emit a bogus offset.

Source

Thrown at src/cmd/internal/dwarf/dwarf.go:978

		// TODO(ribrdb): verify padded strings are never used and remove this
		for i := int64(len(str)); i < value; i++ {
			ctxt.AddInt(s, 1, 0)
		}

	case DW_FORM_flag: // flag
		if value != 0 {
			ctxt.AddInt(s, 1, 1)
		} else {
			ctxt.AddInt(s, 1, 0)
		}

	// As of DWARF 3 the ref_addr is always 32 bits, unless emitting a large
	// (> 4 GB of debug info aka "64-bit") unit, which we don't implement.
	case DW_FORM_ref_addr: // reference to a DIE in the .info section
		fallthrough
	case DW_FORM_sec_offset: // offset into a DWARF section other than .info
		if data == nil {
			return fmt.Errorf("dwarf: null reference in %d", abbrev)
		}
		ctxt.AddDWARFAddrSectionOffset(s, data, value)

	case DW_FORM_addrx: // index into .debug_addr section
		ctxt.AddIndirectTextRef(s, data)

	case DW_FORM_ref1, // reference within the compilation unit
		DW_FORM_ref2,      // reference
		DW_FORM_ref4,      // reference
		DW_FORM_ref8,      // reference
		DW_FORM_ref_udata, // reference

		DW_FORM_strp,     // string
		DW_FORM_indirect: // (see Section 7.5.3)
		fallthrough
	default:
		return fmt.Errorf("dwarf: unsupported attribute form %d / class %d", form, cls)
	}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Rebuild with a stable Go release rather than tip; this is usually a toolchain regression.
  2. File an issue at https://go.dev/issue with the reproducer package and `go version`.
  3. Try simplifying the offending package (split large files, remove heavy generics/inlining) to dodge the triggering DIE.
  4. Temporarily build with `-ldflags=-w` to suppress DWARF and confirm the binary links without it.
Defensive patterns

Strategy: fallback

Prevention

When it happens

Trigger: The DWARF abbreviation table routes an attribute through DW_FORM_ref_addr/DW_FORM_sec_offset but the caller passed nil for the section reference. This is an internal compiler/linker state bug — the abbreviation's form/class disagrees with the supplied data — rather than a user-input error.

Common situations: Encountered when the compiler emits DWARF for unusual constructs (e.g. abstract/concrete inlined functions, cross-CU references) and an abbreviation/form mismatch slips in, typically after a compiler change or on bleeding-edge tip builds. Almost never triggerable by end-user Go source.

Related errors


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