go-delve/delve · error

too many arguments

Error message

too many arguments

What it means

Delve throws this when a function call expression passes more arguments than the target Go function accepts. During call injection Delve evaluates each argument expression and maps it onto the callee's formal parameters read from DWARF; if the argument count exceeds the formal (or variadic-adjusted) arity, injection is aborted before touching the target process.

Source

Thrown at pkg/proc/fncall.go:65

//
// When the target has runtime.debugPinner then evalCallInjectionPinPointer
// must be also called in a loop until it returns false.

const (
	debugCallFunctionNamePrefix1 = "debugCall"
	debugCallFunctionNamePrefix2 = "runtime.debugCall"
	maxDebugCallVersion          = 2
	maxArgFrameSize              = 65535
)

var (
	errFuncCallUnsupported        = errors.New("function calls not supported by this version of Go")
	errFuncCallUnsupportedBackend = errors.New("backend does not support function calls")
	errFuncCallInProgress         = errors.New("cannot call function while another function call is already in progress")
	errNoGoroutine                = errors.New("no goroutine selected")
	errGoroutineNotRunning        = errors.New("selected goroutine not running")
	errNotEnoughStack             = errors.New("not enough stack space")
	errTooManyArguments           = errors.New("too many arguments")
	errNotEnoughArguments         = errors.New("not enough arguments")
	errNotAGoFunction             = errors.New("not a Go function")
	errFuncCallNotAllowedStrAlloc = errors.New("literal string can not be allocated because function calls are not allowed without using 'call'")
)

type functionCallState struct {
	// savedRegs contains the saved registers
	savedRegs Registers
	// err contains a saved error
	err error
	// expr is the expression being evaluated
	expr *ast.CallExpr
	// fn is the function that is being called
	fn *Function
	// receiver is the receiver argument for the function
	receiver *Variable
	// closureAddr is the address of the closure being called
	closureAddr uint64

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Remove the extra arguments to match the function's signature
  2. Check the signature with `print f` or inspect the source before calling
  3. If extra values were meant for a variadic call, call the function that is actually variadic
  4. If the signature changed, update the call to the new arity

Example fix

// before
(dlv) call add(1, 2, 3) // add takes two params
// after
(dlv) call add(1, 2)
Defensive patterns

Strategy: validation

Validate before calling

// verify arity before issuing the call
(dlv) print add // inspect signature
// only call with exactly len(formalArgs) arguments

Try / catch

if err := scope.CallFunction(expr); err != nil && err.Error() == "too many arguments" {
    // fix arity in expr and retry
}

Prevention

When it happens

Trigger: `call f(a, b, c)` where f has only 2 parameters; calling a non-variadic function with extra arguments from the debugger prompt.

Common situations: Typo in arity while calling from the dlv terminal; calling a wrapper function thinking it forwards all args; API changed signature (arg removed) and the user's call is stale.

Related errors


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