go-delve/delve · error
wrong type for pcs item
Error message
wrong type for pcs item %d: %v
What it means
When reconstructing a goroutine stack from the runtime's gp.pcs (or similar) slice, each element is expected to be a uintptr-like reflect.Uint value. If a child variable has any other Kind, the stack cannot be built and this error is thrown. It signals the pcs slice variable was decoded incorrectly or is corrupted.
Solutions
- Upgrade Delve to a version matching the Go toolchain used to build the target (check Delve's supported Go versions).
- Rebuild the target with a supported Go version and re-debug.
- If it persists, report the failing variable Kind to go-delve/delve as a runtime layout mismatch.
Example fix
// before go install github.com/go-delve/delve/cmd/dlv@latest # may lag Go tip // after: pin a Delve release matching your Go version go install github.com/go-delve/delve/cmd/dlv@v1.22.0
Defensive patterns
Strategy: fallback
Try / catch
frames, err := g.Stack(n, opts)
if err != nil && strings.Contains(err.Error(), "wrong type for pcs item") {
// fall back to thread-based stack (Thread.Stacktrace) instead of goroutine pcs
} Prevention
- Match Delve version to the target's Go toolchain version
- Rebuild targets with Go versions supported by your Delve release
- Report persistent mismatches upstream with Go and Delve versions
When it happens
Trigger: Goroutine stack extraction on a target where the pcs slice children were read as something other than unsigned ints (unreadable flag not set but Kind differs) — usually a DWARF layout mismatch or binary/ debugger version skew.
Common situations: Go runtime layout changes vs an outdated Delve version; debugging a binary built with a Go version newer than the Delve release supports.
Related errors
- error derefing *G
- unknown goroutine
- array too long for comparison
- breakpoint can not be enabled
- can not access unreadable map
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/6a3846d047aaef3e.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/proc/variables.go:1118
// Stack returns the stack trace of ancestor 'a' as saved by the runtime.
func (a *Ancestor) Stack(n int) ([]Stackframe, error) {
if a.Unreadable != nil {
return nil, a.Unreadable
}
pcsVar := a.pcsVar.clone()
pcsVar.loadValue(LoadConfig{MaxArrayValues: n})
if pcsVar.Unreadable != nil {
return nil, pcsVar.Unreadable
}
r := make([]Stackframe, len(pcsVar.Children))
for i := range pcsVar.Children {
if pcsVar.Children[i].Unreadable != nil {
r[i] = Stackframe{Err: pcsVar.Children[i].Unreadable}
continue
}
if pcsVar.Children[i].Kind != reflect.Uint {
return nil, fmt.Errorf("wrong type for pcs item %d: %v", i, pcsVar.Children[i].Kind)
}
pc, _ := constant.Int64Val(pcsVar.Children[i].Value)
fn := a.pcsVar.bi.PCToFunc(uint64(pc))
if fn == nil {
loc := Location{PC: uint64(pc)}
r[i] = Stackframe{Current: loc, Call: loc}
continue
}
pc2 := uint64(pc)
if pc2-1 >= fn.Entry {
pc2--
}
f, ln := fn.cu.lineInfo.PCToLine(fn.Entry, pc2)
loc := Location{PC: uint64(pc), File: f, Line: ln, Fn: fn}
r[i] = Stackframe{Current: loc, Call: loc}
}
r[len(r)-1].Bottom = pcsVar.Len == int64(len(pcsVar.Children))
return r, nilView on GitHub (pinned to a23773e6c3)