{"record":{"id":"973543473a6fee09","repo":"go-delve/delve","slug":"could-not-continue-existing-thread-d-s","errorCode":null,"errorMessage":"could not continue existing thread %d %s","messagePattern":"could not continue existing thread (.+?) (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/native/proc_linux.go","lineNumber":544,"sourceCode":"\t\t\t\t}\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif halt {\n\t\t\t\tth.os.running = false\n\t\t\t\tdbp.threads[int(wpid)].os.running = false\n\t\t\t\treturn nil, nil\n\t\t\t}\n\t\t\tif err = th.resume(); err != nil {\n\t\t\t\tif err == sys.ESRCH {\n\t\t\t\t\t// thread died while we were adding it\n\t\t\t\t\tdelete(dbp.threads, th.ID)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\treturn nil, fmt.Errorf(\"could not continue new thread %d %s\", cloned, err)\n\t\t\t}\n\t\t\tif err = dbp.threads[int(wpid)].resume(); err != nil {\n\t\t\t\tif err != sys.ESRCH {\n\t\t\t\t\treturn nil, fmt.Errorf(\"could not continue existing thread %d %s\", wpid, err)\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tif status.StopSignal() == sys.SIGTRAP && (status.TrapCause() == sys.PTRACE_EVENT_EXEC) {\n\t\t\t// A thread called exec and we now have a new process. Retrieve the\n\t\t\t// thread ID of the exec'ing thread with PtraceGetEventMsg to remove it\n\t\t\t// and create a new nativeProcess object to track the new process.\n\t\t\tvar tid uint\n\t\t\tdbp.execPtraceFunc(func() { tid, err = sys.PtraceGetEventMsg(wpid) })\n\t\t\tif err == nil {\n\t\t\t\tdelete(dbp.threads, int(tid))\n\t\t\t}\n\t\t\tdbp = newChildProcess(procgrp.procs[0], wpid)\n\t\t\tdbp.followExec = true\n\t\t\tcmdline, _ := dbp.initializeBasic()\n\t\t\ttgt, err := procgrp.add(dbp, dbp.pid, dbp.memthread, findExecutable(\"\", dbp.pid), proc.StopLaunched, cmdline)\n\t\t\tif err != nil {","sourceCodeStart":526,"sourceCodeEnd":562,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/native/proc_linux.go#L526-L562","documentation":"Immediately after resuming the newly cloned thread, trapWaitInternal also resumes the parent thread (dbp.threads[int(wpid)]) that performed the clone. If that resume fails with an errno other than ESRCH, the wait loop aborts with this error identifying the parent pid and errno. Like error 586, ESRCH (thread vanished) is intentionally treated as benign.","triggerScenarios":"The clone-parent thread is resumed via PTRACE_CONT and fails with a non-ESRCH errno — typically because the parent thread exited concurrently with an unexpected status, or the ptrace connection is broken.","commonSituations":"Programs where the spawning thread exits immediately after creating workers; debuggees killed externally (e.g. OOM killer) mid-clone; restricted ptrace environments (seccomp filters, sandboxed CI runners).","solutions":["Retry the session; this is usually a transient race between thread exit and resume.","Check system logs (dmesg/journalctl) for OOM kills or SIGKILLs of the debuggee around the failure time.","Verify ptrace permissions and absence of competing tracers on the target.","Report to the delve project with the exact errno if consistently reproducible."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// confirm target is not being killed externally\nps -o pid,stat,cmd -p $PID\ndmesg | tail -20 | grep -i -E 'oom|killed'","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"could not continue existing thread\") {\n    // parent thread may have raced with exit; check process state and retry\n    if processAlive(pid) { retrySession(pid) }\n}","preventionTips":["Watch for OOM killer activity in dmesg when debugging memory-heavy targets","Avoid environments that SIGKILL processes (health checkers, supervisors) during debugging","Ensure no competing ptrace consumers are attached","Retry transient failures; escalate to a bug report only when deterministic"],"tags":["linux","ptrace","threads","debugger"],"backgroundTag":"ptrace-resume-failed","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}