go-delve/delve · error
could not load %q: %v
Error message
could not load %q: %v
What it means
When evaluating a function call expression, Delve loads each argument variable's full value before passing it to the called function. If any argument's underlying memory or DWARF data cannot be read (loadValue sets Variable.Unreadable), the whole call evaluation is aborted with this error. It is thrown from the argument-evaluation loop in pkg/proc/eval.go:2073.
Source
Thrown at pkg/proc/eval.go:2073
return minmaxBuiltin("min", token.LSS, args, nodeargs)
}
func maxBuiltin(args []*Variable, nodeargs []ast.Expr) (*Variable, error) {
return minmaxBuiltin("max", token.GTR, args, nodeargs)
}
func minmaxBuiltin(name string, op token.Token, args []*Variable, nodeargs []ast.Expr) (*Variable, error) {
var best *Variable
for i := range args {
if args[i].Kind == reflect.String {
args[i].loadValue(loadFullValueLongerStrings)
} else {
args[i].loadValue(LoadFullValue())
}
if args[i].Unreadable != nil {
return nil, fmt.Errorf("could not load %q: %v", astutil.ExprToString(nodeargs[i]), args[i].Unreadable)
}
if args[i].FloatSpecial != 0 {
return nil, errOperationOnSpecialFloat
}
if best == nil {
best = args[i]
continue
}
_, err := negotiateType(op, args[i], best)
if err != nil {
return nil, err
}
v, err := compareOp(op, args[i], best)
if err != nil {
return nil, errView on GitHub (pinned to a23773e6c3)
Solutions
- Fix the argument expression so it refers to readable memory (e.g. use a live local variable instead of a stale pointer).
- If debugging a core dump, ensure the memory pages backing the argument were captured, or use a core captured with full mappings.
- Simplify the argument (print it first with 'print <expr>') to confirm it is readable before using it in a call.
- If the variable is a register-backed value, dereference or copy it into memory first, or avoid calls that need its full value.
Example fix
// before dlv> call fmt.Println(ptr.String()) // ptr points to unreadable memory // error: could not load "ptr.String()": ... unreadable // after dlv> print ptr // verify the pointer is valid first dlv> call fmt.Println(*ptr) // or use a valid local: call fmt.Println(s)
Defensive patterns
Strategy: validation
Validate before calling
// In the dlv CLI, before using the arg in a call:
// dlv> print <argExpr>
// Programmatic check after evaluating the argument:
if v, err := scope.EvalExpression(argExpr, LoadConfig{FollowPointers: true}); err != nil || v.Unreadable != nil {
// do not use this argument in a call
} Try / catch
// Delve returns errors as values; wrap the eval/call:
res, err := scope.EvalExpression(callExpr, cfg)
if err != nil {
if strings.HasPrefix(err.Error(), "could not load ") {
// fix or skip the offending argument expression
}
} Prevention
- print every argument expression before using it in a call
- avoid calling functions with pointers into unmapped/freed memory
- when using core dumps, verify the needed memory is present
- prefer live locals over stale pointer dereferences as call arguments
When it happens
Trigger: Calling a function in the debuggee (call <fn>(<args>)) where an argument expression evaluates to a variable whose loadValue fails: reading its memory faults (dead/unmapped address), or the variable is a CPU register/special variable that cannot be loaded with the requested full-value load (loadFullValueLongerStrings or LoadFullValue()).
Common situations: Debugging a process whose memory layout changed (e.g. inspecting a core dump where the pointed-to page is not in the dump), calling functions with pointer arguments to freed/unreadable memory, or evaluating in frames where variables live in registers not available in the current frame.
Related errors
- shift count must not be negative
- invalid argument %s (type %s) for cap
- wrong number of arguments to len: %d
- invalid argument %s (type %s) for len
- wrong number of arguments to complex: %d
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/4dc826e0e752e3c8.
Report an issue: GitHub.