go-delve/delve · warning

could not dereference %s: %v

Error message

could not dereference %s: %v

What it means

Delve fails to dereference the 'ctx' (or Windows 'ep') variable while unwinding a stack frame inside runtime.sigtrampgo (the signal handler trampoline). The variable's value could not be loaded from the target process memory (v.Unreadable was set), so the signal context address cannot be recovered and the frame cannot be described.

Source

Thrown at pkg/proc/stack_sigtramp.go:33

func (it *stackIterator) readSigtrampgoContext() (*op.DwarfRegisters, error) {
	logger := logflags.DebuggerLogger()
	scope := FrameToScope(it.target, it.mem, it.g, 0, it.frame)
	bi := it.bi

	findvar := func(name string) *Variable {
		vars, _ := scope.Locals(0, name)
		for i := range vars {
			if vars[i].Name == name {
				return vars[i]
			}
		}
		return nil
	}

	deref := func(v *Variable) (uint64, error) {
		v.loadValue(loadSingleValue)
		if v.Unreadable != nil {
			return 0, fmt.Errorf("could not dereference %s: %v", v.Name, v.Unreadable)
		}
		if len(v.Children) < 1 {
			return 0, fmt.Errorf("could not dereference %s (no children?)", v.Name)
		}
		logger.Debugf("%s address is %#x", v.Name, v.Children[0].Addr)
		return v.Children[0].Addr, nil
	}

	getctxaddr := func() (uint64, error) {
		ctxvar := findvar("ctx")
		if ctxvar == nil {
			return 0, errors.New("ctx variable not found")
		}
		addr, err := deref(ctxvar)
		if err != nil {
			return 0, err
		}
		return addr, nil

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Upgrade or downgrade Delve to a version matching the debugged Go runtime version (runtime variable layout changes break sigtrampgo unwinding)
  2. If debugging a core dump, verify the core includes the memory region holding the signal context (full core, not truncated)
  3. Retry the stack operation; transient memory-read failures (process briefly gone on Linux) may resolve
  4. Check `dlv version` and the Go version used to build the target; report a mismatch as a Delve issue with the Go version and GOOS/GOARCH

Example fix

// before
// unwinding fails: could not dereference ctx: <unreadable>
// after
// install a delve build that supports the target's Go version
go install github.com/go-delve/delve/cmd/dlv@latest
Defensive patterns

Strategy: try-catch

Validate before calling

// Delve internal: before deref, confirm variable loaded cleanly
v.loadValue(loadSingleValue)
if v.Unreadable != nil {
    // skip sigtrampgo unwinding for this frame
}

Type guard

func derefable(v *Variable) bool {
    v.loadValue(loadSingleValue)
    return v.Unreadable == nil && len(v.Children) >= 1
}

Try / catch

regs, err := it.readSigtrampgoContext()
if err != nil {
    // degrade gracefully: fall back to generic frame description
    return it.frame, nil // or log and continue unwinding
}

Prevention

When it happens

Trigger: Raised by the deref closure in readSigtrampgoContext when v.loadValue(loadSingleValue) sets Variable.Unreadable — i.e. reading the pointer variable's memory from the debuggee failed while unwinding a signal frame via sigtrampgo.

Common situations: Debugging a process that received/received-and-handled a signal; the stack contains a sigtrampgo frame and the ctx pointer's memory is unreadable (unmapped address, core dump missing that memory region, corrupt DWARF info for the Go runtime, or mismatched Go version producing wrong variable layout).

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/dc7425c2699c6dba. Report an issue: GitHub.