go-delve/delve · error
not valid
Error message
not valid
What it means
On AMD64 Linux, the ABI has no dedicated link register (return addresses live on the stack), so AMD64Registers.LR() unconditionally panics. The proc.Registers interface includes LR for architectures like ARM64; calling it on AMD64 is always a logic error in the caller.
Source
Thrown at pkg/proc/linutil/regs_amd64_arch.go:134
func (r *AMD64Registers) BP() uint64 {
return r.Regs.Rbp
}
// TLS returns the address of the thread local storage memory segment.
func (r *AMD64Registers) TLS() uint64 {
return r.Regs.Fs_base
}
// GAddr returns the address of the G variable if it is known, 0 and false
// otherwise.
func (r *AMD64Registers) GAddr() (uint64, bool) {
return 0, false
}
// LR returns the link register.
func (r *AMD64Registers) LR() uint64 {
panic("not valid")
}
// Copy returns a copy of these registers that is guaranteed not to change.
func (r *AMD64Registers) Copy() (proc.Registers, error) {
if r.loadFpRegs != nil {
err := r.loadFpRegs(r)
r.loadFpRegs = nil
if err != nil {
return nil, err
}
}
var rr AMD64Registers
rr.Regs = &AMD64PtraceRegs{}
rr.Fpregset = &amd64util.AMD64Xstate{}
*(rr.Regs) = *(r.Regs)
if r.Fpregset != nil {
*(rr.Fpregset) = *(r.Fpregset)
}View on GitHub (pinned to a23773e6c3)
Solutions
- Only call LR() when the target architecture has a link register (arm64, etc.)
- Use PC() and stack-pointer/frame APIs for unwinding on AMD64
- Gate architecture-specific code with runtime.GOARCH or build tags
Example fix
// before
lr := regs.LR()
// after
var lr uint64
if goarch.IsArm64 > 0 { // or runtime.GOARCH == "arm64"
lr = regs.LR()
} Defensive patterns
Strategy: type-guard
Validate before calling
if runtime.GOARCH == "amd64" { /* no LR: do not call */ } Type guard
func hasLinkRegister() bool {
switch runtime.GOARCH {
case "arm64", "riscv64", "loong64", "ppc64le":
return true
}
return false
} Try / catch
defer func() {
if r := recover(); r != nil { err = fmt.Errorf("LR unavailable: %v", r) }
}() Prevention
- Check runtime.GOARCH before arch-specific register access
- Use PC/CFA-based unwinding on amd64/i386
- Keep arch-specific code behind build tags
When it happens
Trigger: Calling registers.LR() on an AMD64Registers value, e.g. frame-unwinding or stack-tracing code that assumes a RISC-style link register without checking GOARCH.
Common situations: Writing architecture-generic code that reads LR unconditionally; porting tools built on pkg/proc from ARM64 to AMD64; plugins/scripts built on delve internals.
Related errors
- not valid
- wrong number of bytes for register %s (%d)
- could not restore RFLAGS register: %v
- wrong number of bytes for register %s (%d)
- can not set %s
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/fd125f91437aeb5e.
Report an issue: GitHub.