{"record":{"id":"ca48524798bbf9a6","repo":"go-delve/delve","slug":"could-not-read-context-v","errorCode":null,"errorMessage":"could not read context: %v","messagePattern":"could not read context: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/stack_sigtramp.go","lineNumber":651,"sourceCode":"\t\t\tlow  uint64\n\t\t\thigh int64\n\t\t}\n\t\tvectorcontrol        uint64\n\t\tdebugcontrol         uint64\n\t\tlastbranchtorip      uint64\n\t\tlastbranchfromrip    uint64\n\t\tlastexceptiontorip   uint64\n\t\tlastexceptionfromrip uint64\n\t}\n\n\tctxtaddr, err := sigtrampContextFromExceptionPointers(mem, addr)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbuf := make([]byte, unsafe.Sizeof(context{}))\n\t_, err = mem.ReadMemory(buf, ctxtaddr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not read context: %v\", err)\n\t}\n\tctxt := (*context)(unsafe.Pointer(&buf[0]))\n\n\tdregs := make([]*op.DwarfRegister, regnum.AMD64MaxRegNum()+1)\n\n\tdregs[regnum.AMD64_Cs] = op.DwarfRegisterFromUint64(uint64(ctxt.segcs))\n\tdregs[regnum.AMD64_Ds] = op.DwarfRegisterFromUint64(uint64(ctxt.segds))\n\tdregs[regnum.AMD64_Es] = op.DwarfRegisterFromUint64(uint64(ctxt.seges))\n\tdregs[regnum.AMD64_Fs] = op.DwarfRegisterFromUint64(uint64(ctxt.segfs))\n\tdregs[regnum.AMD64_Fs] = op.DwarfRegisterFromUint64(uint64(ctxt.seggs))\n\tdregs[regnum.AMD64_Ss] = op.DwarfRegisterFromUint64(uint64(ctxt.segss))\n\tdregs[regnum.AMD64_Rflags] = op.DwarfRegisterFromUint64(uint64(ctxt.eflags))\n\tdregs[regnum.AMD64_Rax] = op.DwarfRegisterFromUint64(ctxt.rax)\n\tdregs[regnum.AMD64_Rcx] = op.DwarfRegisterFromUint64(ctxt.rcx)\n\tdregs[regnum.AMD64_Rdx] = op.DwarfRegisterFromUint64(ctxt.rdx)\n\tdregs[regnum.AMD64_Rbx] = op.DwarfRegisterFromUint64(ctxt.rbx)\n\tdregs[regnum.AMD64_Rsp] = op.DwarfRegisterFromUint64(ctxt.rsp)\n\tdregs[regnum.AMD64_Rbp] = op.DwarfRegisterFromUint64(ctxt.rbp)","sourceCodeStart":633,"sourceCodeEnd":669,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/stack_sigtramp.go#L633-L669","documentation":"On linux/amd64, after obtaining the address of runtime.sigtrampgo's context, Delve reads sizeof(context) bytes from the debuggee to reconstruct the CPU register state saved by the signal handler. The memory read failed, so the signal frame's registers cannot be recovered.","triggerScenarios":"Raised in sigtrampContextLinuxAMD64 when mem.ReadMemory(buf, ctxtaddr) returns an error while reading the ucontext at ctxtaddr during stack unwinding of a signal frame.","commonSituations":"Core dump analysis where the page containing the ucontext/sigcontext is not in the core file; debugging a process whose memory at that address was unmapped; corrupted context address from a wrong dereference; cross-Go-version layout mismatch making the computed address wrong.","solutions":["If using core dumps, regenerate with a fuller core (raise RLIMIT_CORE / use systemd-coredump with full storage, or kernel.core_pattern without truncation)","Verify the Delve and Go runtime versions match so the context address was computed correctly","Retry against a live process if the core dump is incomplete","Report to Delve with GOOS/GOARCH, Go version and whether the dump was truncated if versions match"],"exampleFix":"// before\n// ulimit -c 0 (or small limit) -> truncated core, context page missing\n// after\nulimit -c unlimited\n// or in systemd: Storage=full in coredump.conf","handlingStrategy":"fallback","validationCode":"// verify the context address is mapped before the bulk read\nn, err := mem.ReadMemory(buf[:1], ctxtaddr)\nif err != nil || n != 1 {\n    // address unreadable: do not attempt full context read\n}","typeGuard":null,"tryCatchPattern":"dregs, err := sigtrampContextLinuxAMD64(mem, addr)\nif err != nil {\n    // fall back to a frame without recovered registers\n    return nil, err // caller can still show the frame sans regs\n}","preventionTips":["Capture complete core dumps (ulimit -c unlimited; systemd Storage=full)","Do not partially strip or post-process core files","Keep Delve/Go versions aligned so the computed context address is correct","Treat signal-frame register recovery as best-effort in tooling"],"tags":["delve","debugger","memory-read","core-dump","signal-handling","amd64"],"backgroundTag":"could-not-read-context-memory","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}