{"record":{"id":"676d36c205e1c1e8","repo":"go-delve/delve","slug":"invalid-type-s-in-slice-array","errorCode":null,"errorMessage":"Invalid type %s in slice array","messagePattern":"Invalid type (.+?) in slice array","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/variables.go","lineNumber":1635,"sourceCode":"\tsliceCapFieldName   = \"cap\"\n)\n\nfunc (v *Variable) loadSliceInfo(t *godwarf.SliceType) {\n\tv.mem = cacheMemory(v.mem, v.Addr, int(t.Size()))\n\n\tvar err error\n\tfor _, f := range t.Field {\n\t\tswitch f.Name {\n\t\tcase sliceArrayFieldName:\n\t\t\tvar base uint64\n\t\t\tbase, err = readUintRaw(v.mem, uint64(int64(v.Addr)+f.ByteOffset), f.Type.Size())\n\t\t\tif err == nil {\n\t\t\t\tv.Base = base\n\t\t\t\t// Dereference array type to get value type\n\t\t\t\tptrType, ok := f.Type.(*godwarf.PtrType)\n\t\t\t\tif !ok {\n\t\t\t\t\t//lint:ignore ST1005 backwards compatibility\n\t\t\t\t\tv.Unreadable = fmt.Errorf(\"Invalid type %s in slice array\", f.Type)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tv.fieldType = ptrType.Type\n\t\t\t}\n\t\tcase sliceLenFieldName:\n\t\t\tlstrAddr, _ := v.toField(f)\n\t\t\tlstrAddr.loadValue(loadSingleValue)\n\t\t\terr = lstrAddr.Unreadable\n\t\t\tif err == nil {\n\t\t\t\tv.Len, _ = constant.Int64Val(lstrAddr.Value)\n\t\t\t}\n\t\tcase sliceCapFieldName:\n\t\t\tcstrAddr, _ := v.toField(f)\n\t\t\tcstrAddr.loadValue(loadSingleValue)\n\t\t\terr = cstrAddr.Unreadable\n\t\t\tif err == nil {\n\t\t\t\tv.Cap, _ = constant.Int64Val(cstrAddr.Value)\n\t\t\t}","sourceCodeStart":1617,"sourceCodeEnd":1653,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/variables.go#L1617-L1653","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before: evaluating a cgo/union-typed field that Delve thinks is a slice\nprint myVal\n// Invalid type union {...} in slice array\n// after: cast/re-extract the actual Go slice before inspecting\nprint myVal.goSlice\n","handlingStrategy":"validation","validationCode":"// Before relying on a slice value from delve, check readability\nif v.Unreadable != nil { /* handle: not a well-formed slice type */ }\nif _, ok := v.DwarfType.(*godwarf.SliceType); !ok { /* not a real slice */ }","typeGuard":"func isWellFormedSlice(v *proc.Variable) bool {\n    if v == nil || v.Unreadable != nil { return false }\n    _, ok := v.DwarfType.(*godwarf.SliceType)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["delve","dwarf","slice","variables"],"backgroundTag":"malformed-dwarf-type","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}