{"record":{"id":"dc899c14aeb37753","repo":"go-delve/delve","slug":"undefined-return-address-at-x","errorCode":null,"errorMessage":"Undefined return address at %#x","messagePattern":"Undefined return address at %#x","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/stack.go","lineNumber":767,"sourceCode":"\t// $GDB_SOURCE/dwarf2/frame.c\n\tcallFrameRegs.AddReg(callFrameRegs.SPRegNum, cfareg)\n\n\tfor i, regRule := range framectx.Regs {\n\t\tif logflags.Stack() {\n\t\t\tlogger.Debugf(\"\\t%s rule %s \", it.bi.Arch.RegnumToString(i), ruleString(&regRule, it.bi.Arch.RegnumToString))\n\t\t}\n\t\treg, err := it.executeFrameRegRule(i, regRule, it.regs.CFA)\n\t\tif reg != nil {\n\t\t\tlogger.Debugf(\"\\t\\t-> %#x\", reg.Uint64Val)\n\t\t} else {\n\t\t\tlogger.Debugf(\"\\t\\t-> nothing (%v)\", err)\n\t\t}\n\t\tcallFrameRegs.AddReg(i, reg)\n\t\tif i == framectx.RetAddrReg {\n\t\t\tif reg == nil {\n\t\t\t\tif err == nil {\n\t\t\t\t\t//lint:ignore ST1005 backwards compatibility\n\t\t\t\t\terr = fmt.Errorf(\"Undefined return address at %#x\", it.pc)\n\t\t\t\t}\n\t\t\t\tit.err = err\n\t\t\t} else {\n\t\t\t\tret = reg.Uint64Val\n\t\t\t\t// On systems which use a link register to store the return address of a function,\n\t\t\t\t// certain leaf functions may not have correct DWARF information present in the\n\t\t\t\t// .debug_frame FDE when unwinding after a fatal signal. This is due to the fact\n\t\t\t\t// that runtime.sigpanic inserts a frame to make it look like the function which\n\t\t\t\t// triggered the signal called runtime.sigpanic directly, making the value of the\n\t\t\t\t// link register unreliable. Instead, treat it as a non-leaf function and read the\n\t\t\t\t// return address from the stack. For more details, see:\n\t\t\t\t// https://github.com/golang/go/issues/63862#issuecomment-1802672629.\n\t\t\t\tif it.frame.Call.Fn != nil && it.frame.Call.Fn.Name == \"runtime.sigpanic\" && it.bi.Arch.usesLR {\n\t\t\t\t\tbuf := make([]byte, 8)\n\t\t\t\t\t_, err := it.mem.ReadMemory(buf, uint64(it.regs.CFA))\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tit.err = err\n\t\t\t\t\t}","sourceCodeStart":749,"sourceCodeEnd":785,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/stack.go#L749-L785","documentation":"After evaluating DWARF rules for all registers, Delve reads the return-address register (RetAddrReg). If that rule produced no register (undefined), the function's return address cannot be determined and the stack walk must stop. Error is raised at the PC where the undefined rule was found.","triggerScenarios":"advanceRegsDWARF on a frame whose DWARF CFI marks the return address register undefined — typical for frame-less leaf functions or the outermost (start) function, or when CFI for the PC is missing so the retained register is nil.","commonSituations":"Walking past the bottom of the stack into runtime.startup assembly; debugging optimized/assembly functions with incomplete DWARF; version mismatch where Go emitted CFI that Delve's parser treats as undefined.","solutions":["Treat this as end-of-stack if it occurs at the outermost frame (normal terminator in some cases)","Rebuild with an up-to-date Go toolchain and without stripping debug info","Update Delve to get improved Go runtime CFI handling","Skip the broken frame manually in tooling instead of full-stack iteration"],"exampleFix":"null","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"frames, err := iterateFrames(); if err != nil && strings.Contains(err.Error(), \"Undefined return address\") { /* use frames already collected; at outermost frame this is normal termination */ }","preventionTips":["Treat undefined ret-addr at the bottom frame as end-of-stack, not an error","Build with up-to-date Go toolchains for complete CFI","Avoid aggressive frame-pointer/DWARF stripping","Update Delve for improved leaf-function ret-addr heuristics"],"tags":["dwarf","stack","return-address","unwinding"],"backgroundTag":"undefined-return-address","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}