go-delve/delve · error
Invalid type %s in slice array
Error message
Invalid type %s in slice array
What it means
Delve throws this while loading a slice's underlying array storage. It expects the DWARF type of the 'array' field to be a pointer to the element type; any other type means the DWARF info is not shaped like a Go slice, so the value is marked unreadable.
Source
Thrown at pkg/proc/variables.go:1635
sliceCapFieldName = "cap"
)
func (v *Variable) loadSliceInfo(t *godwarf.SliceType) {
v.mem = cacheMemory(v.mem, v.Addr, int(t.Size()))
var err error
for _, f := range t.Field {
switch f.Name {
case sliceArrayFieldName:
var base uint64
base, err = readUintRaw(v.mem, uint64(int64(v.Addr)+f.ByteOffset), f.Type.Size())
if err == nil {
v.Base = base
// Dereference array type to get value type
ptrType, ok := f.Type.(*godwarf.PtrType)
if !ok {
//lint:ignore ST1005 backwards compatibility
v.Unreadable = fmt.Errorf("Invalid type %s in slice array", f.Type)
return
}
v.fieldType = ptrType.Type
}
case sliceLenFieldName:
lstrAddr, _ := v.toField(f)
lstrAddr.loadValue(loadSingleValue)
err = lstrAddr.Unreadable
if err == nil {
v.Len, _ = constant.Int64Val(lstrAddr.Value)
}
case sliceCapFieldName:
cstrAddr, _ := v.toField(f)
cstrAddr.loadValue(loadSingleValue)
err = cstrAddr.Unreadable
if err == nil {
v.Cap, _ = constant.Int64Val(cstrAddr.Value)
}View on GitHub (pinned to a23773e6c3)
Solutions
- Rebuild the binary with standard 'go build' (no -ldflags stripping of debug info) so slice types have proper pointer DWARF types
- Check the variable is actually a Go slice and not a struct that merely resembles one
- Re-generate the core dump or re-attach; stale/mismatched binaries vs debug info cause type mismatches
- Inspect the DWARF type of the variable with 'objdump --dwarf=info' to confirm the array field is a pointer type
Example fix
// before: evaluating a cgo/union-typed field that Delve thinks is a slice
print myVal
// Invalid type union {...} in slice array
// after: cast/re-extract the actual Go slice before inspecting
print myVal.goSlice
Defensive patterns
Strategy: validation
Validate before calling
// Before relying on a slice value from delve, check readability
if v.Unreadable != nil { /* handle: not a well-formed slice type */ }
if _, ok := v.DwarfType.(*godwarf.SliceType); !ok { /* not a real slice */ } Type guard
func isWellFormedSlice(v *proc.Variable) bool {
if v == nil || v.Unreadable != nil { return false }
_, ok := v.DwarfType.(*godwarf.SliceType)
return ok
} Prevention
- Debug binaries built with standard go toolchain flags
- Never strip DWARF (-w) from binaries you intend to inspect
- Match binary and debug-info/core dump versions exactly
When it happens
Trigger: Evaluating a variable whose DWARF type is a slice but whose 'array' struct field has a non-pointer type, typically due to corrupted or non-Go-generated DWARF (cgo unions, optimized binaries with fabricated types, or malformed debug info).
Common situations: Debugging binaries compiled with unusual flags or linker plugins, mixed C/Go debug info, or evaluating values from stripped/relocated core dumps where the array field type got rewritten.
Related errors
- wrong real type for map
- could not read %d bytes from register %d (size: %d), also er
- could not read %d bytes from register %d (size: %d)
- could not read %d bytes from address %#x: %v
- could not dereference %s (no children?)
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/676d36c205e1c1e8.
Report an issue: GitHub.