{"record":{"id":"cf87ebea3149dca8","repo":"go-delve/delve","slug":"can-not-change-register-values-of-core-process","errorCode":null,"errorMessage":"can not change register values of core process","messagePattern":"can not change register values of core process","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/core/core.go","lineNumber":193,"sourceCode":"\ntype osThread interface {\n\tRegisters() (proc.Registers, error)\n\tThreadID() int\n}\n\nvar (\n\t// ErrWriteCore is returned when attempting to write to the core\n\t// process memory.\n\tErrWriteCore = errors.New(\"can not write to core process\")\n\n\t// ErrShortRead is returned on a short read.\n\tErrShortRead = errors.New(\"short read\")\n\n\t// ErrContinueCore is returned when trying to continue execution of a core process.\n\tErrContinueCore = errors.New(\"can not continue execution of core process\")\n\n\t// ErrChangeRegisterCore is returned when trying to change register values for core files.\n\tErrChangeRegisterCore = errors.New(\"can not change register values of core process\")\n)\n\ntype openFn func(string, string) (*process, proc.Thread, error)\n\nvar openFns = []openFn{readLinuxOrPlatformIndependentCore, readAMD64Minidump}\n\n// ErrUnrecognizedFormat is returned when the core file is not recognized as\n// any of the supported formats.\nvar ErrUnrecognizedFormat = errors.New(\"unrecognized core format\")\n\n// OpenCore will open the core file and return a *proc.TargetGroup.\n// If the DWARF information cannot be found in the binary, Delve will look\n// for external debug files in the directories passed in.\nfunc OpenCore(corePath, exePath string, debugInfoDirs []string) (*proc.TargetGroup, error) {\n\tvar p *process\n\tvar currentThread proc.Thread\n\tvar err error\n\tfor _, openFn := range openFns {","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/core/core.go#L175-L211","documentation":"ErrChangeRegisterCore (pkg/proc/core/core.go:193) is returned by register-mutating APIs (RestoreRegisters, SetPC, SetSP, SetDX, SetReg) when invoked on a core-file backend. Because a core dump is a read-only snapshot, registers cannot be modified. Only reads via ReadRegister/ListDynRegisters succeed.","triggerScenarios":"Calling SetPC/SetSP/SetDX/SetReg or RestoreRegisters on a process obtained from OpenCore, e.g. when replaying a fix by patching registers, or via RPC clients that set registers before continuing.","commonSituations":"Scripts that emulate 'jump to recovery code' by changing PC on cores; generic debugger tooling that unconditionally writes registers; trying to 'unwind and fix' a core the way you would a live process.","solutions":["Avoid register writes in core-file sessions; treat register state as read-only evidence.","Gate register-mutation code on the backend type before calling SetReg/SetPC etc.","Reproduce the fault in a live debug session where register writes are supported.","Simulate the effect of a register change by computing values in your analysis instead of mutating the core."],"exampleFix":"// before\nthread.SetPC(fixupAddr) // -> can not change register values of core process\n\n// after\nif isCoreDump(target) {\n    fmt.Println(\"read-only core: PC fixup unsupported; inspecting instead\")\n} else {\n    thread.SetPC(fixupAddr)\n}","handlingStrategy":"validation","validationCode":"if isCoreTarget(tg) { return errors.New(\"registers are read-only in core sessions\") }","typeGuard":"func registersWritable(tg *proc.TargetGroup) bool { return !isCoreTarget(tg) }","tryCatchPattern":"err := thread.SetPC(addr)\nif errors.Is(err, core.ErrChangeRegisterCore) {\n    log.Println(\"read-only core: register modification rejected\")\n}","preventionTips":["Treat all register setters as live-debug-only APIs.","Gate register-mutation features by backend in RPC clients.","Prefer computing fixed-up values in your analysis instead of writing them.","Re-run the failing scenario live when you need to change execution state."],"tags":["core-dump","registers","go","delve"],"backgroundTag":"core-file-not-executable","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}