{"record":{"id":"4fe8b267d6a92db1","repo":"go-delve/delve","slug":"traverse-failed-with-error-w","errorCode":null,"errorMessage":"traverse failed with error %w","messagePattern":"traverse failed with error %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/debugger/debugger.go","lineNumber":1399,"sourceCode":"// Functions returns a list of functions in the target process.\nfunc (d *Debugger) Functions(filter string, followCalls int) ([]string, error) {\n\td.targetMutex.Lock()\n\tdefer d.targetMutex.Unlock()\n\n\tregex, err := regexp.Compile(filter)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid filter argument: %s\", err.Error())\n\t}\n\n\tfuncs := []string{}\n\tt := proc.ValidTargets{Group: d.target}\n\tfor t.Next() {\n\t\tfor _, f := range t.BinInfo().Functions {\n\t\t\tif regex.MatchString(f.Name) {\n\t\t\t\tif followCalls > 0 {\n\t\t\t\t\tnewfuncs, err := d.traverse(t, &f, 1, followCalls, filter)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"traverse failed with error %w\", err)\n\t\t\t\t\t}\n\t\t\t\t\tfuncs = append(funcs, newfuncs...)\n\t\t\t\t} else {\n\t\t\t\t\tfuncs = append(funcs, f.Name)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tsort.Strings(funcs)\n\tfuncs = slices.Compact(funcs)\n\treturn funcs, nil\n}\n\nfunc (d *Debugger) traverse(t proc.ValidTargets, f *proc.Function, depth int, followCalls int, rootstr string) ([]string, error) {\n\ttype TraceFunc struct {\n\t\tFunc    *proc.Function\n\t\tDepth   int\n\t\tvisited bool","sourceCodeStart":1381,"sourceCodeEnd":1417,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/debugger/debugger.go#L1381-L1417","documentation":"Returned by Debugger.Functions when a regex-matched function is walked with followCalls > 0 and the internal call-graph traversal (d.traverse) fails. The traverse walks a BFS over disassembled call instructions of the matched function and any error it encounters (disassembly failure, breakpoint setup failure, callback errors) is wrapped with this message. It means the follow-calls expansion of the function list could not be completed, so no usable function list is returned.","triggerScenarios":"Calling Debugger.Functions(filter, followCalls) with followCalls > 0 via RPC2 (or terminal `functions <filter> <followCalls>`) when: the target's memory cannot be disassembled (corrupt/unmapped code region, non-native backend without disassembly support), a temporary breakpoint cannot be set inside a dynamic-call site, or the runtime callback (stack trace / register read / tracepoint creation) fails during dynamic-call resolution.","commonSituations":"Debugging a core dump or stripped binary where Disassemble cannot decode a function's instructions; using follow-calls tracing on a Go binary built for an unsupported architecture; followCalls depth large enough that traversal reaches runtime stubs or dynamically linked regions; process exited or memory unreadable mid-traversal.","solutions":["Read the wrapped inner error (%w) in the message to find the real failing step (disassemble, SetBreakpoint, stack trace, or registers).","Retry with followCalls=0 to confirm plain Functions(filter) works, isolating the failure to the traversal path.","Lower the followCalls depth so traversal stops before deep/runtime functions whose code cannot be disassembled.","Check the process is alive and the backend supports disassembly (e.g. core/gdbserial backends have restricted memory access).","Verify the binary is a supported architecture and not stripped/corrupt (go tool nm / dlv check)."],"exampleFix":"// before\nfuncs, err := client.Functions(\"main\\.\", 5)\n// after\nfuncs, err := client.Functions(\"main\\.\", 0) // list only\nif err == nil {\n    funcs, err = client.Functions(\"main\\.\", 2) // smaller followCalls depth\n}","handlingStrategy":"try-catch","validationCode":"// validate the filter regex compiles before the RPC call\nif _, err := regexp.Compile(filter); err != nil {\n    return fmt.Errorf(\"invalid filter: %w\", err)\n}\nif followCalls < 0 {\n    return fmt.Errorf(\"followCalls must be >= 0\")\n}","typeGuard":"// errors.As to unwrap the underlying cause\nvar inner error\nif errors.As(err, &inner) || strings.Contains(err.Error(), \"traverse failed\") {\n    log.Printf(\"follow-calls traversal failed: %v\", err)\n}","tryCatchPattern":"funcs, err := client.Functions(filter, followCalls)\nif err != nil && strings.Contains(err.Error(), \"traverse failed\") {\n    log.Printf(\"follow-calls unavailable, falling back: %v\", err)\n    funcs, err = client.Functions(filter, 0)\n}","preventionTips":["Always compile-validate the filter regex client-side first.","Start with followCalls=0 and increase only as needed.","Keep followCalls shallow (2-3) to limit traversal into runtime internals.","Ensure the backend supports disassembly and breakpoints (native, not core dump).","Unwrap with errors.As/Unwrap to log the root cause, not just the wrapper."],"tags":["debugger","follow-calls","call-graph","traversal"],"backgroundTag":"call-graph-traversal-failed","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}