{"record":{"id":"7f85aeb1de6bdb56","repo":"go-delve/delve","slug":"could-not-determine-current-location-scope-is-nil","errorCode":null,"errorMessage":"could not determine current location (scope is nil)","messagePattern":"could not determine current location \\(scope is nil\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/locspec/locations.go","lineNumber":305,"sourceCode":"\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\tr := make([]api.Location, 0, len(matches))\n\tfor i := range matches {\n\t\taddrs, _ := proc.FindFunctionLocation(t, matches[i], 0)\n\t\tif len(addrs) > 0 {\n\t\t\tr = append(r, addressesToLocation(addrs))\n\t\t}\n\t}\n\treturn r, \"\", nil\n}\n\n// Find returns the locations specified via the address location spec.\nfunc (loc *AddrLocationSpec) Find(t *proc.Target, _ []string, scope *proc.EvalScope, locStr string, includeNonExecutableLines bool, _ [][2]string) ([]api.Location, string, error) {\n\tif scope == nil {\n\t\taddr, err := strconv.ParseInt(loc.AddrExpr, 0, 64)\n\t\tif err != nil {\n\t\t\treturn nil, \"\", errors.New(\"could not determine current location (scope is nil)\")\n\t\t}\n\t\treturn []api.Location{{PC: uint64(addr)}}, \"\", nil\n\t}\n\n\tv, err := scope.EvalExpression(loc.AddrExpr, proc.LoadConfig{FollowPointers: true})\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\tif v.Unreadable != nil {\n\t\treturn nil, \"\", v.Unreadable\n\t}\n\tswitch v.Kind {\n\tcase reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:\n\t\taddr, _ := constant.Uint64Val(v.Value)\n\t\treturn []api.Location{{PC: addr}}, \"\", nil\n\tcase reflect.Func:\n\t\tfn := scope.BinInfo.PCToFunc(v.Base)\n\t\tpc, err := proc.FirstPCAfterPrologue(t, fn, false)","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/locspec/locations.go#L287-L323","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nlocs, err := addrSpec.Find(target, nil, nil, \"myVar+4\", false, nil) // nil scope\n// after\nlocs, err := addrSpec.Find(target, nil, scope, \"myVar+4\", false, nil) // scope from running target","handlingStrategy":"validation","validationCode":"if scope == nil {\n    if _, err := strconv.ParseInt(addrSpec.AddrExpr, 0, 64); err != nil {\n        return errors.New(\"without a running target only literal addresses (e.g. 0x401000) are supported\")\n    }\n}","typeGuard":null,"tryCatchPattern":"locs, _, err := spec.Find(t, funcs, scope, locStr, false, nil)\nif err != nil && strings.Contains(err.Error(), \"scope is nil\") {\n    return fmt.Errorf(\"cannot evaluate address expression without a target: %w\", err)\n}","preventionTips":["Use literal hex addresses for pre-launch breakpoints","Launch/attach before symbolic address expressions","Validate address expressions parse as integers before calling Find"],"tags":["breakpoints","debugger-state"],"backgroundTag":"nil-eval-scope","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}