go-delve/delve · error
malformed variable DIE (name)
Error message
malformed variable DIE (name)
What it means
readVarEntry extracts the name of a variable from its DWARF DIE (debug info entry). If the DIE has no dwarf.AttrName attribute, or the attribute is not a string, the variable entry is considered malformed and this error is thrown. This indicates corrupt, truncated, or unexpectedly-shaped DWARF debug information rather than a bug in the caller's code.
Source
Thrown at pkg/proc/variables.go:1216
if field.Name == memberName {
return structVar.toField(field)
}
if field.Name == "&"+memberName && closure {
f, err := structVar.toField(field)
if err != nil {
return nil, err
}
return f.maybeDereference(), nil
}
}
return nil, fmt.Errorf("%s has no member %s", vname, memberName)
}
func readVarEntry(entry *godwarf.Tree, image *Image) (name string, typ godwarf.Type, err error) {
name, ok := entry.Val(dwarf.AttrName).(string)
if !ok {
return "", nil, errors.New("malformed variable DIE (name)")
}
typ, err = entry.Type(image.dwarf, image.index, image.typeCache)
if err != nil {
return "", nil, err
}
return name, typ, nil
}
// Extracts the name and type of a variable from a dwarf entry
// then executes the instructions given in the DW_AT_location attribute to grab the variable's address
func extractVarInfoFromEntry(tgt *Target, bi *BinaryInfo, image *Image, regs op.DwarfRegisters, mem MemoryReadWriter, entry *godwarf.Tree, dictAddr uint64) (*Variable, error) {
if entry.Tag != dwarf.TagFormalParameter && entry.Tag != dwarf.TagVariable {
return nil, fmt.Errorf("invalid entry tag, only supports FormalParameter and Variable, got %s", entry.Tag.String())
}
n, t, err := readVarEntry(entry, image)View on GitHub (pinned to a23773e6c3)
Solutions
- Rebuild the binary with full, unstripped debug info (do not use -ldflags='-s -w') and retry.
- Upgrade delve to the latest version so it can parse DWARF emitted by your Go compiler version.
- Verify the executable is not truncated/corrupted (rebuild or re-download it).
- If the binary comes from a third party, ask for a build with standard Go toolchain flags.
- Bisect the Go toolchain version if the failure started after a compiler upgrade.
Example fix
// before dlv exec ./app-stripped-binary // after go build -gcflags="all=-N -l" -o ./app . dlv exec ./app
Defensive patterns
Strategy: type-guard
Validate before calling
name, ok := entry.Val(dwarf.AttrName).(string)
if !ok || name == "" {
// skip or regenerate debug info for this DIE
return
} Type guard
func hasVarName(entry *godwarf.Tree) bool {
_, ok := entry.Val(dwarf.AttrName).(string)
return ok
} Try / catch
v, err := readVarEntry(tree, image)
if err != nil {
if strings.Contains(err.Error(), "malformed variable DIE") {
// fall back: skip this variable, log DIE offset
return
}
return err
} Prevention
- Always build debug binaries without -ldflags="-s -w"
- Keep delve and Go toolchain versions aligned
- Verify binary integrity (checksum) when downloaded from elsewhere
When it happens
Trigger: Calling APIs that resolve variables by DIE (e.g. variable evaluation that goes through readVarEntry) when the compiled binary's DWARF info lacks a name attribute on the variable DIE — typically due to stripped/mangled debug info, compiler bugs, or optimizations emitting partial DIEs.
Common situations: Debugging binaries built with unusual flags (-w -s then partially restored symbols), binaries produced by non-standard toolchains or linkers, corrupted executables, or newer Go/compiler versions emitting DWARF shapes the delve version in use does not understand.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- unable to find function context
- unable to find locals: no debug information present in binar
- malformed map type: buckets, oldbuckets or overflow field no
- ctx variable not found
- ep variable not found
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/3a325b938a74e0da.
Report an issue: GitHub.