{"record":{"id":"596b19ecaa5d8434","repo":"go-delve/delve","slug":"could-not-determine-location-scope-is-nil","errorCode":null,"errorMessage":"could not determine location (scope is nil)","messagePattern":"could not determine location \\(scope is nil\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/locspec/locations.go","lineNumber":283,"sourceCode":"\t}\n\treturn true\n}\n\nfunc packageMatch(specPkg, symPkg string, packageMap map[string][]string) bool {\n\tfor _, pkg := range packageMap[specPkg] {\n\t\tif partialPackageMatch(pkg, symPkg) {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn partialPackageMatch(specPkg, symPkg)\n}\n\n// Find will search all functions in the target program and filter them via the\n// regex location spec. Only functions matching the regex will be returned.\nfunc (loc *RegexLocationSpec) Find(t *proc.Target, _ []string, scope *proc.EvalScope, locStr string, includeNonExecutableLines bool, _ [][2]string) ([]api.Location, string, error) {\n\tif scope == nil {\n\t\t//TODO(aarzilli): this needs only the list of function we should make it work\n\t\treturn nil, \"\", errors.New(\"could not determine location (scope is nil)\")\n\t}\n\tfuncs := scope.BinInfo.Functions\n\tmatches, err := regexFilterFuncs(loc.FuncRegex, funcs)\n\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) {","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/locspec/locations.go#L265-L301","documentation":"RegexLocationSpec.Find resolves a regex location spec (e.g. breakpoints like b /main\\..*/) by filtering scope.BinInfo.Functions. It needs an EvalScope to access the binary info; when scope is nil there is no current frame to obtain it from, so the search cannot run and this error is returned.","triggerScenarios":"Calling Find with a nil *proc.EvalScope while the target is not running — e.g. setting a regex breakpoint before launch/attach, or calling the API without a current goroutine/frame.","commonSituations":"Scripting dlv via the API and setting breakpoints before starting the program; issuing regex breakpoints from a state where the process is not yet attached.","solutions":["Start/attach to the target before setting regex breakpoints so a valid scope exists","Resolve the function list independently (proc.Functions from the loaded BinInfo) and filter it yourself","Check scope != nil before invoking Find and report a clearer error to the user"],"exampleFix":"// before\nlocs, err := locspec.Find(target, funcs, nil, \"/main\\..*/\", false, nil)\n// after\nif scope == nil {\n    return errors.New(\"target must be running to use regex breakpoints\")\n}\nlocs, err := locspec.Find(target, funcs, scope, \"/main\\..*/\", false, nil)","handlingStrategy":"validation","validationCode":"if scope == nil {\n    return errors.New(\"regex breakpoints require a running target\")\n}\nlocs, err := spec.Find(target, funcs, scope, locStr, false, dirs)","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(\"start or attach to the target before setting this breakpoint: %w\", err)\n}","preventionTips":["Set function-name breakpoints only after launch/attach","In API clients, create the EvalScope from the current goroutine before Find","Prefer AbsoluteFileLocationSpecs when no scope exists"],"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"}