go-delve/delve · error
could not determine current location (scope is nil)
Error message
could not determine current location (scope is nil)
What it means
AddrLocationSpec.Find resolves an address/expression location spec. If scope is nil it can still handle a plain numeric address expression by parsing it directly; but if that parse fails (the expression is not a constant address), it has no scope to evaluate the expression against and returns this error.
Source
Thrown at pkg/locspec/locations.go:305
if err != nil {
return nil, "", err
}
r := make([]api.Location, 0, len(matches))
for i := range matches {
addrs, _ := proc.FindFunctionLocation(t, matches[i], 0)
if len(addrs) > 0 {
r = append(r, addressesToLocation(addrs))
}
}
return r, "", nil
}
// Find returns the locations specified via the address location spec.
func (loc *AddrLocationSpec) Find(t *proc.Target, _ []string, scope *proc.EvalScope, locStr string, includeNonExecutableLines bool, _ [][2]string) ([]api.Location, string, error) {
if scope == nil {
addr, err := strconv.ParseInt(loc.AddrExpr, 0, 64)
if err != nil {
return nil, "", errors.New("could not determine current location (scope is nil)")
}
return []api.Location{{PC: uint64(addr)}}, "", nil
}
v, err := scope.EvalExpression(loc.AddrExpr, proc.LoadConfig{FollowPointers: true})
if err != nil {
return nil, "", err
}
if v.Unreadable != nil {
return nil, "", v.Unreadable
}
switch v.Kind {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
addr, _ := constant.Uint64Val(v.Value)
return []api.Location{{PC: addr}}, "", nil
case reflect.Func:
fn := scope.BinInfo.PCToFunc(v.Base)
pc, err := proc.FirstPCAfterPrologue(t, fn, false)View on GitHub (pinned to a23773e6c3)
Solutions
- Use a literal address (e.g. 0x401000) when setting breakpoints before launch, or start the program first
- Verify the address expression parses as an integer (strconv.ParseInt with base 0) before calling
- Attach/launch the target so a valid EvalScope is available for expression evaluation
Example fix
// before locs, err := addrSpec.Find(target, nil, nil, "myVar+4", false, nil) // nil scope // after locs, err := addrSpec.Find(target, nil, scope, "myVar+4", false, nil) // scope from running target
Defensive patterns
Strategy: validation
Validate before calling
if scope == nil {
if _, err := strconv.ParseInt(addrSpec.AddrExpr, 0, 64); err != nil {
return errors.New("without a running target only literal addresses (e.g. 0x401000) are supported")
}
} Try / catch
locs, _, err := spec.Find(t, funcs, scope, locStr, false, nil)
if err != nil && strings.Contains(err.Error(), "scope is nil") {
return fmt.Errorf("cannot evaluate address expression without a target: %w", err)
} Prevention
- Use literal hex addresses for pre-launch breakpoints
- Launch/attach before symbolic address expressions
- Validate address expressions parse as integers before calling Find
When it happens
Trigger: Calling Find with a nil scope and an AddrExpr that is not a parseable integer literal (e.g. "myVar" or "ptr+0x10"), since evaluating such expressions requires an EvalScope.
Common situations: Setting a breakpoint at a symbolic address/expression before the program is running; passing an invalid or malformed address string like "xyz" instead of a hex address.
Related errors
- could not determine location (scope is nil)
- Malformed breakpoint location, no line offset specified
- could not determine current location
- cannot write a breakpoint to a core file
- runtime.copystack has too many return instructions
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/7f85aeb1de6bdb56.
Report an issue: GitHub.