go-delve/delve · warning
literal string can not be allocated because function calls a
Error message
literal string can not be allocated because function calls are not allowed without using 'call'
What it means
Delve throws this when evaluating an expression that requires allocating a new string (e.g. concatenating or slicing strings) while function call injection is disabled. Allocating a string requires calling runtime.mallocgc in the target, i.e. a hidden function call, which Delve only permits when calls are allowed (the `call` command or configuration permitting calls); otherwise the literal cannot be materialized.
Source
Thrown at pkg/proc/fncall.go:68
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
// formalArgs are the formal arguments of fn
formalArgs []funcCallArg
// argFrameSize contains the size of the argumentsView on GitHub (pinned to a23773e6c3)
Solutions
- Use the `call` command explicitly instead of print when string allocation is needed
- Enable function calls in configuration/target so allocation can run
- Reformulate the expression to avoid creating new strings (print existing variables separately)
- Upgrade the Go version if calls are entirely unsupported
Example fix
// before
(dlv) print "x=" + name // needs mallocgc, calls disallowed
// after
(dlv) call fmt.Sprintf("x=%s", name) Defensive patterns
Strategy: fallback
Validate before calling
// avoid allocation-forcing expressions when calls are disallowed: // prefer printing existing variables over "a" + b concatenations // (dlv) print a; (dlv) print b
Try / catch
v, err := scope.EvalExpression(expr, cfg)
if err != nil && strings.Contains(err.Error(), "literal string can not be allocated") {
// retry with the `call` command or enable function calls
} Prevention
- Use `call` (not print) for expressions that allocate strings
- Enable function-call support in the debug target/config
- Reformulate expressions to avoid creating new strings
- Upgrade Go if function calls are entirely unsupported
When it happens
Trigger: Evaluating `"a" + b` or `s[i:]` producing a new string with a non-`call` command (print/display) while `call` injection is disallowed by target/config; Delve's `-allow-non-method-functions`/step behavior restricting calls.
Common situations: Printing concatenated strings at a breakpoint in a configuration that forbids function calls; CI/production debugging where injection is disabled; older Go versions where calls are unsupported.
Related errors
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/0a9eff2409bf8197.
Report an issue: GitHub.