{"record":{"id":"0a9eff2409bf8197","repo":"go-delve/delve","slug":"literal-string-can-not-be-allocated-because-functi","errorCode":null,"errorMessage":"literal string can not be allocated because function calls are not allowed without using 'call'","messagePattern":"literal string can not be allocated because function calls are not allowed without using 'call'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/proc/fncall.go","lineNumber":68,"sourceCode":"\nconst (\n\tdebugCallFunctionNamePrefix1 = \"debugCall\"\n\tdebugCallFunctionNamePrefix2 = \"runtime.debugCall\"\n\tmaxDebugCallVersion          = 2\n\tmaxArgFrameSize              = 65535\n)\n\nvar (\n\terrFuncCallUnsupported        = errors.New(\"function calls not supported by this version of Go\")\n\terrFuncCallUnsupportedBackend = errors.New(\"backend does not support function calls\")\n\terrFuncCallInProgress         = errors.New(\"cannot call function while another function call is already in progress\")\n\terrNoGoroutine                = errors.New(\"no goroutine selected\")\n\terrGoroutineNotRunning        = errors.New(\"selected goroutine not running\")\n\terrNotEnoughStack             = errors.New(\"not enough stack space\")\n\terrTooManyArguments           = errors.New(\"too many arguments\")\n\terrNotEnoughArguments         = errors.New(\"not enough arguments\")\n\terrNotAGoFunction             = errors.New(\"not a Go function\")\n\terrFuncCallNotAllowedStrAlloc = errors.New(\"literal string can not be allocated because function calls are not allowed without using 'call'\")\n)\n\ntype functionCallState struct {\n\t// savedRegs contains the saved registers\n\tsavedRegs Registers\n\t// err contains a saved error\n\terr error\n\t// expr is the expression being evaluated\n\texpr *ast.CallExpr\n\t// fn is the function that is being called\n\tfn *Function\n\t// receiver is the receiver argument for the function\n\treceiver *Variable\n\t// closureAddr is the address of the closure being called\n\tclosureAddr uint64\n\t// formalArgs are the formal arguments of fn\n\tformalArgs []funcCallArg\n\t// argFrameSize contains the size of the arguments","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/fncall.go#L50-L86","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n(dlv) print \"x=\" + name   // needs mallocgc, calls disallowed\n// after\n(dlv) call fmt.Sprintf(\"x=%s\", name)","handlingStrategy":"fallback","validationCode":"// avoid allocation-forcing expressions when calls are disallowed:\n// prefer printing existing variables over \"a\" + b concatenations\n// (dlv) print a; (dlv) print b","typeGuard":null,"tryCatchPattern":"v, err := scope.EvalExpression(expr, cfg)\nif err != nil && strings.Contains(err.Error(), \"literal string can not be allocated\") {\n    // retry with the `call` command or enable function calls\n}","preventionTips":["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"],"tags":["debugger","function-call-injection","string-allocation"],"backgroundTag":"call-injection-disabled","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}