go-delve/delve · error

mismatched length in addrs and addrpid

Error message

mismatched length in addrs and addrpid

What it means

When creating a breakpoint at explicit addresses across multiple processes, Delve accepts a parallel Addrs and AddrPid slices whose elements correspond index-by-index. This error is returned when the two slices have different lengths, since Delve cannot determine which pid each address belongs to.

Source

Thrown at service/debugger/debugger.go:751

					}
				}
			}
		}
		setbp.File = fileName
		setbp.Line = requestedBp.Line
	case len(requestedBp.FunctionName) > 0:
		setbp.FunctionName = requestedBp.FunctionName
		setbp.Line = requestedBp.Line
	case len(requestedBp.Addrs) > 0:
		setbp.PidAddrs = make([]proc.PidAddr, len(requestedBp.Addrs))
		if len(d.target.Targets()) == 1 {
			pid := d.target.Selected.Pid()
			for i, addr := range requestedBp.Addrs {
				setbp.PidAddrs[i] = proc.PidAddr{Pid: pid, Addr: addr}
			}
		} else {
			if len(requestedBp.Addrs) != len(requestedBp.AddrPid) {
				return nil, errors.New("mismatched length in addrs and addrpid")
			}
			for i, addr := range requestedBp.Addrs {
				setbp.PidAddrs[i] = proc.PidAddr{Pid: requestedBp.AddrPid[i], Addr: addr}
			}
		}
	default:
		if requestedBp.Addr != 0 {
			setbp.PidAddrs = []proc.PidAddr{{Pid: d.target.Selected.Pid(), Addr: requestedBp.Addr}}
		}
	}

	if locExpr != "" {
		loc, err := locspec.Parse(locExpr)
		if err != nil {
			return nil, err
		}
		setbp.Expr = func(t *proc.Target) []uint64 {
			locs, _, err := loc.Find(t, d.processArgs, nil, locExpr, false, substitutePathRules)

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Fix the caller so AddrPid has exactly one entry per address in Addrs
  2. If all addresses belong to one process, set requestedBp.Pid instead and leave AddrPid empty
  3. Validate slice lengths on the client before invoking CreateBreakpoint

Example fix

// before
bp := &api.Breakpoint{Addrs: []uint64{0x1000, 0x2000}, AddrPid: []int{123}}
// after
bp := &api.Breakpoint{Addrs: []uint64{0x1000, 0x2000}, AddrPid: []int{123, 456}}
Defensive patterns

Strategy: validation

Validate before calling

if len(bp.Addrs) > 0 && bp.Pid == 0 && len(bp.Addrs) != len(bp.AddrPid) {
    return errors.New("Addrs and AddrPid must have equal length")
}

Type guard

func addrsWellFormed(bp *api.Breakpoint) bool {
    return bp.Pid != 0 || len(bp.Addrs) == len(bp.AddrPid)
}

Try / catch

_, err := dbg.CreateBreakpoint(bp)
if err != nil && strings.Contains(err.Error(), "mismatched length in addrs and addrpid") {
    // fix client-side slice construction and retry
}

Prevention

When it happens

Trigger: Calling Debugger.CreateBreakpoint with requestedBp.Addrs and requestedBp.AddrPid set to slices of unequal length and no single Pid specified (multi-target mode).

Common situations: Client-side bugs in tools constructing the api.Breakpoint programmatically; partial population of AddrPid after collecting addresses from several child processes; serialization mistakes in custom Delve frontends.

Related errors


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