go-delve/delve · info · ErrProcessDetached

detached from the process

Error message

detached from the process

What it means

ErrProcessDetached signals that delve has already detached from the target process, so the target state is no longer valid and operations on it fail. It is returned by the Valid() check that guards most TargetGroup operations. It prevents use-after-detach bugs rather than indicating a debugging failure.

Source

Thrown at pkg/proc/target.go:28

	"sync"

	"github.com/go-delve/delve/pkg/dwarf/op"
	"github.com/go-delve/delve/pkg/goversion"
	"github.com/go-delve/delve/pkg/logflags"
	"github.com/go-delve/delve/pkg/proc/internal/ebpf"
)

var (
	// ErrNotRecorded is returned when an action is requested that is
	// only possible on recorded (traced) programs.
	ErrNotRecorded = errors.New("not a recording")

	// ErrNoRuntimeAllG is returned when the runtime.allg list could
	// not be found.
	ErrNoRuntimeAllG = errors.New("could not find goroutine array")

	// ErrProcessDetached indicates that we detached from the target process.
	ErrProcessDetached = errors.New("detached from the process")
)

type LaunchFlags uint8

const (
	LaunchForeground LaunchFlags = 1 << iota
	LaunchDisableASLR
)

// Target represents the process being debugged.
type Target struct {
	Process

	proc   ProcessInternal
	recman RecordingManipulationInternal

	pid     int
	CmdLine string

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Do not issue further commands after Detach; treat the session as closed
  2. Check for ErrProcessDetached from Valid() and re-launch/reattach if more work is needed
  3. Serialize client requests so no command runs concurrently with Detach
  4. Create a new debugger session for the process if you need to debug again

Example fix

// before
_, err := tgrp.Valid()
stepErr := tgrp.Step() // fails with 'detached from the process'
// after
if _, err := tgrp.Valid(); errors.Is(err, proc.ErrProcessDetached) {
    return restartSessionAndReattach()
}
Defensive patterns

Strategy: try-catch

Validate before calling

_, err := tgrp.Valid()
if err != nil { // includes ErrProcessDetached
    return
}

Type guard

func detached(t *proc.TargetGroup) bool {
    _, err := t.Valid()
    return errors.Is(err, proc.ErrProcessDetached)
}

Try / catch

if _, err := tgrp.Valid(); errors.Is(err, proc.ErrProcessDetached) {
    // session closed; reattach or exit cleanly
}

Prevention

When it happens

Trigger: Calling any operation that first runs grp.Valid()/t.Valid() (e.g. Continue, Next, Breakpoints) after a Detach call completed on the target.

Common situations: Clients issuing commands after a 'detach' in the terminal; race between a Detach RPC and in-flight evaluate/continue requests in IDE integrations; scripted sessions that keep driving the API post-detach.

Related errors


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