go-delve/delve · error
examine memory error: %w
Error message
examine memory error: %w
What it means
After the address is resolved, DAP's examineMemory delegates to debugger.ExamineMemory to read target process memory. Any failure from that read (unmapped page, exited process, invalid address, truncated count) is wrapped as 'examine memory error: %w'. The wrapped inner error carries the actual cause.
Source
Thrown at service/dap/command.go:201
address = uint64(n)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: // "-x 0xc000079f20 + 8" or -x 824634220320 + 8
address, _ = constant.Uint64Val(val.Value)
default:
return fmt.Errorf("unsupported expression type: %s", val.Kind).Error(), nil
}
} else {
address, err = strconv.ParseUint(args.Operand, 0, 64)
if err != nil {
return fmt.Errorf("convert address into uintptr type failed, %s", err).Error(), nil
}
}
memory, err := s.debugger.ExamineMemory(
address,
min(int(args.Count*args.Size), rpc2.ExamineMemoryLengthLimit),
)
if err != nil {
return fmt.Errorf("examine memory error: %w", err).Error(), nil
}
return api.PrettyExamineMemory(uintptr(address), memory, true, args.Format, int(args.Size)), nil
}
func (s *Session) evaluateConfig(_, _ int, expr string) (string, error) {
argv := config.Split2PartsBySpace(expr)
name := argv[0]
if name == "-list" {
if len(argv) > 1 {
return config.ConfigureListByName(&s.args, argv[1], "cfgName"), nil
}
return listConfig(&s.args), nil
}
updated, res, err := configureSet(&s.args, expr)
if err != nil {
return "", err
}View on GitHub (pinned to a23773e6c3)
Solutions
- Read the wrapped cause (%w) to identify whether the address is unmapped, the process exited, or the read was too large.
- Re-derive the address from a live expression with 'examine-memory -x &var' instead of reusing a stale literal address.
- Reduce the count/size so the read stays within the mapped region (and under rpc2.ExamineMemoryLengthLimit).
- Ensure the target is alive and stopped at a breakpoint before examining memory.
Example fix
// before: reusing stale address examine-memory 0xc000014000 // after: evaluate the live pointer examine-memory -x &myStruct
Defensive patterns
Strategy: try-catch
Try / catch
if out, err := doExamineMemory(addr, count); err != nil {
var cause string
if unwrapped := errors.Unwrap(err); unwrapped != nil {
cause = unwrapped.Error() // distinguish unmapped vs exited process
}
log.Printf("examine-memory failed: %v (cause: %s)", err, cause)
} Prevention
- Re-evaluate pointers with -x instead of caching literal addresses across steps
- Keep reads small and within one mapped region
- Ensure the target is stopped and alive before reading memory
When it happens
Trigger: Calling examine-memory with an address that is not mapped in the debuggee, reading after the target has exited or is not stopped, requesting Count*Size bytes spanning an unmapped region, or a backend memory-read failure (ptrace/gdbserial/core error).
Common situations: Reading a stale address after the program re-ran or reallocated; typo in a hand-copied address; examining memory in a core dump or remote session where the page is not present; debugging a process that was killed between steps.
Related errors
- bad arguments: %w
- bug? invalid pointer: %#v
- unsupported expression type: %s
- convert address into uintptr type failed, %s
- count/len must be a positive integer
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/34c0bbbfca460db4.
Report an issue: GitHub.