go-delve/delve · error

member data has no data member location attribute

Error message

member data has no data member location attribute

What it means

Returned by Reader.InstructionsForEntry when the entry is a member (TagMember) but its DW_AT_data_member_location attribute is not a []byte expression. Member location is sometimes a plain integer offset; in that case this error is raised instead of returning instructions.

Source

Thrown at pkg/dwarf/reader/reader.go:199

	}
	var attr dwarf.Attr
	if member {
		attr = dwarf.AttrDataMemberLoc
	} else {
		attr = dwarf.AttrLocation
	}
	instr, ok := entry.Val(attr).([]byte)
	if !ok {
		return nil, errors.New("invalid typecast for Dwarf instructions")
	}
	return instr, nil
}

func (reader *Reader) InstructionsForEntry(entry *dwarf.Entry) ([]byte, error) {
	if entry.Tag == dwarf.TagMember {
		instructions, ok := entry.Val(dwarf.AttrDataMemberLoc).([]byte)
		if !ok {
			return nil, errors.New("member data has no data member location attribute")
		}
		// clone slice to prevent stomping on the dwarf data
		return append([]byte{}, instructions...), nil
	}

	// non-member
	instructions, ok := entry.Val(dwarf.AttrLocation).([]byte)
	if !ok {
		return nil, errors.New("entry has no location attribute")
	}

	// clone slice to prevent stomping on the dwarf data
	return append([]byte{}, instructions...), nil
}

// NextMemberVariable moves the reader to the next debug entry that describes a member variable and returns the entry.
func (reader *Reader) NextMemberVariable() (*dwarf.Entry, error) {
	for {

View on GitHub (pinned to a23773e6c3)

Solutions

  1. If the attribute is an integer constant, compute the offset directly instead of asking for instructions
  2. Verify the member entry with a DWARF dumper to see the attribute's actual form
  3. Regenerate debug info with a toolchain that emits expression-form member locations if expression evaluation is required

Example fix

// before
instr, err := reader.InstructionsForEntry(memberEntry)
// after
off, ok := memberEntry.Val(dwarf.AttrDataMemberLoc).(int64)
if ok {
    return off // constant offset, no DWARF program
}
instr, err := reader.InstructionsForEntry(memberEntry)
Defensive patterns

Strategy: type-guard

Type guard

func memberOffset(e *dwarf.Entry) (int64, []byte, bool) {
    switch v := e.Val(dwarf.AttrDataMemberLoc).(type) {
    case int64:
        return v, nil, true
    case []byte:
        return 0, v, true
    }
    return 0, nil, false
}

Prevention

When it happens

Trigger: InstructionsForEntry on a struct member whose AttrDataMemberLoc is missing or is an int offset rather than a DWARF expression byte slice.

Common situations: Members of C-like/aligned structs where the producer emits a constant offset, hand-built dwarf.Entry values in tests, or older DWARF forms encoding member offset as a constant.

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/022ce6fac63cd742. Report an issue: GitHub.