{"record":{"id":"1ecf9dfaaf868a7f","repo":"go-delve/delve","slug":"v-also-v","errorCode":null,"errorMessage":"%v also %v","messagePattern":"%v also %v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/native/proc_windows.go","lineNumber":173,"sourceCode":"\t}\n\n\tif waitFor.Valid() {\n\t\tvar err error\n\t\tpid, err = WaitFor(waitFor)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\n\tdbp := newProcess(pid)\n\tvar err error\n\tdbp.execPtraceFunc(func() {\n\t\t// TODO: Probably should have SeDebugPrivilege before starting here.\n\t\terr = _DebugActiveProcess(uint32(pid))\n\t})\n\tif err != nil {\n\t\tif aperr != nil {\n\t\t\treturn nil, fmt.Errorf(\"%v also %v\", err, aperr)\n\t\t}\n\t\treturn nil, err\n\t}\n\texepath, err := findExePath(pid)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ttgt, err := dbp.initialize(exepath, []string{})\n\tif err != nil {\n\t\tdetachWithoutGroup(dbp, true)\n\t\treturn nil, err\n\t}\n\treturn tgt, nil\n}\n\n// acquireDebugPrivilege acquires the debug privilege which is needed to\n// debug other user's processes.\n// See:","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/native/proc_windows.go#L155-L191","documentation":"In the Windows backend's Attach, Delve first tries to attach to the already-running process (often in response to a race where the target exited or was spawned by another mechanism — the recorded aperr from that earlier attempt). If _DebugActiveProcess then also fails, both errors are combined with \"%v also %v\" so the developer sees the original attach failure plus the DebugActiveProcess failure.","triggerScenarios":"Calling debugger Attach(pid) on Windows where an initial attach attempt failed (aperr set) and the subsequent _DebugActiveProcess call also fails — e.g. the process exited between attempts, or the caller lacks debug privileges.","commonSituations":"Attaching to a process that just crashed or exited (race condition); attaching without SeDebugPrivilege to a process owned by another user; attaching to a protected/PPL process; a stale PID from a wrapper script.","solutions":["Read the second error (the DebugActiveProcess one) for the root cause; the first is the earlier attach attempt's error.","Re-check that the PID is still alive before attaching (`tasklist /FI \"PID eq <pid>\"`).","Run Delve elevated (Administrator) so SeDebugPrivilege is available.","Retry attach promptly after launching the target to avoid the exit race."],"exampleFix":"// before\ndlv attach 4242\n// error: exit status 1 also Access is denied.\n// after\n# run as Administrator, and verify PID first\ntasklist /FI \"PID eq 4242\"\ndlv attach 4242","handlingStrategy":"try-catch","validationCode":"// windows\nout, _ := exec.Command(\"tasklist\", \"/FI\", fmt.Sprintf(\"PID eq %d\", pid)).Output()\nalive := strings.Contains(string(out), strconv.Itoa(pid))\n_ = alive // attach only if the pid still exists","typeGuard":null,"tryCatchPattern":"_, err := dbg.Attach(pid, []string{})\nif err != nil {\n    var ex proc.ErrProcessExited\n    if errors.As(err, &ex) {\n        // target died during attach; restart it and re-attach\n    } else {\n        // privilege or access problem; check the second error in the message\n    }\n}","preventionTips":["Run the debugger elevated on Windows.","Verify the PID is alive immediately before attaching.","Avoid long delays between launching and attaching the target."],"tags":["windows","attach","process-exited","privileges"],"backgroundTag":"debug-attach-failed","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}