go-delve/delve · error

can not start a call injection while running backwards

Error message

can not start a call injection while running backwards

What it means

Delve's gdbserial backend returns this when a call injection (function call via breakpoint injection) is requested while the recorded target is being run in reverse (rr record/replay backwards). Call injection is only meaningful for forward execution; attempting it while direction is backward is rejected to avoid corrupting replay state.

Source

Thrown at pkg/proc/gdbserial/gdbserver.go:137

		}

		xcodePath := strings.TrimSpace(string(stdout))
		if xcodePath == "" {
			return ""
		}

		// xcode-select prints the path to the active Developer directory, which is typically a sibling to SharedFrameworks.
		return filepath.Join(xcodePath, "..", debugserverXcodeRelativeExecutablePath)
	}(),
}

// ErrDirChange is returned when trying to change execution direction
// while there are still internal breakpoints set.
var ErrDirChange = errors.New("direction change with internal breakpoints")

// ErrStartCallInjectionBackwards is returned when trying to start a call
// injection while the recording is being run backwards.
var ErrStartCallInjectionBackwards = errors.New("can not start a call injection while running backwards")

var checkCanUnmaskSignalsOnce sync.Once
var canUnmaskSignalsCached bool

// gdbProcess implements proc.Process using a connection to a debugger stub
// that understands Gdb Remote Serial Protocol.
type gdbProcess struct {
	bi       *proc.BinaryInfo
	regnames *gdbRegnames
	conn     gdbConn

	threads       map[int]*gdbThread
	currentThread *gdbThread

	exited, detached bool
	almostExited     bool // true if 'rr' has sent its synthetic SIGKILL
	ctrlC            bool // ctrl-c was sent to stop inferior

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Set direction back to forward before the call: proc.ChangeDirection(proc.Forward) then retry the call injection.
  2. Postpone/avoid function-call evaluation while reverse-running; use plain variable reads instead.
  3. If using rr, stop the reverse continue/step so the process is idle before evaluating calls.
  4. Check delve version: newer versions may gracefully defer call injection instead of erroring.

Example fix

// before (during reverse execution)
err := grp.Selected.CallFunction(...)
// after
p.ChangeDirection(proc.Forward)
err := grp.Selected.CallFunction(...)
Defensive patterns

Strategy: validation

Validate before calling

if p.Dir() == proc.Backward {
    return errors.New("switch to forward direction before call injection")
}

Prevention

When it happens

Trigger: Calling proc.ProcessInternal start-call-injection style APIs (e.g. via debugger call injection during a replay session) while proc.Direction is Backward.

Common situations: Using rr reverse debugging with delve and issuing a call (e.g. printing a function call in the CLI, conditional breakpoints with call expressions) while reverse-stepping/backward continue is active.

Related errors


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