go-delve/delve · error
error derefing *G %s
Error message
error derefing *G %s
What it means
When decoding a runtime G struct, if the variable's real type is a *G pointer, the code first reads the pointer target address from memory (readUintRaw). If that raw memory read fails (unmapped memory, dead process, bad address), the error is wrapped as 'error derefing *G <cause>'. The goroutine state cannot be decoded.
Source
Thrown at pkg/proc/variables.go:895
tid int
}
func (ng ErrNoGoroutine) Error() string {
return fmt.Sprintf("no G executing on thread %d", ng.tid)
}
var ErrUnreadableG = errors.New("could not read G struct")
func (v *Variable) parseG() (*G, error) {
mem := v.mem
gaddr := v.Addr
_, deref := v.RealType.(*godwarf.PtrType)
if deref {
var err error
gaddr, err = readUintRaw(mem, gaddr, int64(v.bi.Arch.PtrSize()))
if err != nil {
return nil, fmt.Errorf("error derefing *G %s", err)
}
}
if gaddr == 0 {
id := 0
if thread, ok := mem.(Thread); ok {
id = thread.ThreadID()
}
return nil, ErrNoGoroutine{tid: id}
}
isptr := func(t godwarf.Type) bool {
_, ok := t.(*godwarf.PtrType)
return ok
}
for isptr(v.RealType) {
v = v.maybeDereference() // +rtype g
}
v.mem = cacheMemory(v.mem, v.Addr, int(v.RealType.Size()))View on GitHub (pinned to a23773e6c3)
Solutions
- Read the wrapped cause (after 'error derefing *G ') to see the underlying memory error and act on it.
- Verify the process is still alive and the attached binary matches the running one.
- Retry after the target stops again; if debugging a core, confirm the core is complete (full memory dump).
Defensive patterns
Strategy: try-catch
Validate before calling
state, err := client.GetState()
if err != nil { return err } // target must be stopped and alive before decoding goroutines
if state.Exited { return errors.New("target exited; G decode impossible") } Try / catch
g, err := proc.DecodeG(mem, gaddr, thread)
if err != nil && strings.HasPrefix(err.Error(), "error derefing *G") {
// memory read failed: process dying or bad address; re-acquire state and retry once
} Prevention
- Only decode goroutines while the target is fully stopped
- Re-check process liveness after each continue/step
- Use complete core dumps (full memory) when core debugging
When it happens
Trigger: Decoding thread/goroutine state where gaddr points through a pointer whose memory read fails — reading registers or memory of a thread whose process is dying, or a corrupted g pointer.
Common situations: Attaching to a crashing/exiting process; core dump debugging where the G pointer references a page not in the core; corrupted runtime state from a broken binary.
Related errors
- write out of bounds
- can not access unreadable map: %v
- could not load swiss table groups data: %v
- could not load swiss map group: %v
- unknown goroutine %d
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/02b1d521689ea333.
Report an issue: GitHub.