{"record":{"id":"6b1329f869ea9bc4","repo":"go-delve/delve","slug":"mismatched-length-in-addrs-and-addrpid","errorCode":null,"errorMessage":"mismatched length in addrs and addrpid","messagePattern":"mismatched length in addrs and addrpid","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/debugger/debugger.go","lineNumber":751,"sourceCode":"\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tsetbp.File = fileName\n\t\tsetbp.Line = requestedBp.Line\n\tcase len(requestedBp.FunctionName) > 0:\n\t\tsetbp.FunctionName = requestedBp.FunctionName\n\t\tsetbp.Line = requestedBp.Line\n\tcase len(requestedBp.Addrs) > 0:\n\t\tsetbp.PidAddrs = make([]proc.PidAddr, len(requestedBp.Addrs))\n\t\tif len(d.target.Targets()) == 1 {\n\t\t\tpid := d.target.Selected.Pid()\n\t\t\tfor i, addr := range requestedBp.Addrs {\n\t\t\t\tsetbp.PidAddrs[i] = proc.PidAddr{Pid: pid, Addr: addr}\n\t\t\t}\n\t\t} else {\n\t\t\tif len(requestedBp.Addrs) != len(requestedBp.AddrPid) {\n\t\t\t\treturn nil, errors.New(\"mismatched length in addrs and addrpid\")\n\t\t\t}\n\t\t\tfor i, addr := range requestedBp.Addrs {\n\t\t\t\tsetbp.PidAddrs[i] = proc.PidAddr{Pid: requestedBp.AddrPid[i], Addr: addr}\n\t\t\t}\n\t\t}\n\tdefault:\n\t\tif requestedBp.Addr != 0 {\n\t\t\tsetbp.PidAddrs = []proc.PidAddr{{Pid: d.target.Selected.Pid(), Addr: requestedBp.Addr}}\n\t\t}\n\t}\n\n\tif locExpr != \"\" {\n\t\tloc, err := locspec.Parse(locExpr)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tsetbp.Expr = func(t *proc.Target) []uint64 {\n\t\t\tlocs, _, err := loc.Find(t, d.processArgs, nil, locExpr, false, substitutePathRules)","sourceCodeStart":733,"sourceCodeEnd":769,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/debugger/debugger.go#L733-L769","documentation":"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.","triggerScenarios":"Calling Debugger.CreateBreakpoint with requestedBp.Addrs and requestedBp.AddrPid set to slices of unequal length and no single Pid specified (multi-target mode).","commonSituations":"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.","solutions":["Fix the caller so AddrPid has exactly one entry per address in Addrs","If all addresses belong to one process, set requestedBp.Pid instead and leave AddrPid empty","Validate slice lengths on the client before invoking CreateBreakpoint"],"exampleFix":"// before\nbp := &api.Breakpoint{Addrs: []uint64{0x1000, 0x2000}, AddrPid: []int{123}}\n// after\nbp := &api.Breakpoint{Addrs: []uint64{0x1000, 0x2000}, AddrPid: []int{123, 456}}","handlingStrategy":"validation","validationCode":"if len(bp.Addrs) > 0 && bp.Pid == 0 && len(bp.Addrs) != len(bp.AddrPid) {\n    return errors.New(\"Addrs and AddrPid must have equal length\")\n}","typeGuard":"func addrsWellFormed(bp *api.Breakpoint) bool {\n    return bp.Pid != 0 || len(bp.Addrs) == len(bp.AddrPid)\n}","tryCatchPattern":"_, err := dbg.CreateBreakpoint(bp)\nif err != nil && strings.Contains(err.Error(), \"mismatched length in addrs and addrpid\") {\n    // fix client-side slice construction and retry\n}","preventionTips":["Build Addrs and AddrPid together in one loop so they can't diverge","Prefer setting Pid when all addresses belong to a single process","Add client-side invariant checks before marshaling api.Breakpoint over RPC"],"tags":["breakpoint","validation","multi-process","rpc"],"backgroundTag":"mismatched-array-lengths","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}