{"record":{"id":"face3f464807c9e2","repo":"go-delve/delve","slug":"could-not-continue-new-thread-d-s-face3f","errorCode":null,"errorMessage":"could not continue new thread %d %s","messagePattern":"could not continue new thread (.+?) (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/native/proc_linux.go","lineNumber":540,"sourceCode":"\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, int(cloned))\n\t\t\t\t\tcontinue\n\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)","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/native/proc_linux.go#L522-L558","documentation":"After adding a newly cloned thread (from a PTRACE_EVENT_CLONE/VFORK stop), trapWaitInternal calls th.resume() to let the new thread run. If resuming fails with an errno other than ESRCH (thread already died, which is silently tolerated), Delve aborts the wait loop with this error naming the cloned pid and the underlying errno. It signals the debugger could not return the new thread to execution during thread setup.","triggerScenarios":"dbp.addThread(cloned) succeeds but th.resume() (which issues PTRACE_CONT via the backend) fails with EPERM, EIO, or similar non-ESRCH errno for the freshly cloned tid.","commonSituations":"Race where the new thread exits between addThread and resume but the exit status hasn't been reaped yet (yielding EIO/EPERM instead of ESRCH); ptrace restrictions in hardened containers; kernel version quirks around clone stops.","solutions":["Retry the debugging session — this is usually a transient race between thread creation and thread exit.","Confirm ptrace permissions (yama ptrace_scope, CAP_SYS_PTRACE in containers).","Ensure nothing else is sending signals to or tracing the new thread concurrently.","If reproducible on a specific workload, capture the errno from the message and report it to the delve project."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// check for external signal killers / competing tracers before session\nps -o tracer= -p $PID\ncat /proc/sys/kernel/yama/ptrace_scope","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"could not continue new thread\") {\n    // transient clone/resume race: retry the session after a short delay\n    time.Sleep(200 * time.Millisecond)\n    retrySession(pid)\n}","preventionTips":["Attach to quiescent processes rather than ones spawning/terminating threads at high rate","Do not SIGKILL individual threads of a debuggee during a session","Run in environments without seccomp filters that block PTRACE_CONT","Retry the session before investigating deeper — most failures are transient races"],"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"}