{"record":{"id":"423fd4b7ddef9389","repo":"go-delve/delve","slug":"unable-to-clear-breakpoint-d-v","errorCode":null,"errorMessage":"unable to clear breakpoint %d: %v","messagePattern":"unable to clear breakpoint (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/target_group.go","lineNumber":441,"sourceCode":"\t\t\t\tn++\n\t\t\t\terr := it.ClearBreakpoint(bp.Addr)\n\t\t\t\tif err != nil {\n\t\t\t\t\terrs = append(errs, err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif len(errs) > 0 {\n\t\tbuf := new(bytes.Buffer)\n\t\tfor i, err := range errs {\n\t\t\tfmt.Fprintf(buf, \"%s\", err)\n\t\t\tif i != len(errs)-1 {\n\t\t\t\tfmt.Fprintf(buf, \", \")\n\t\t\t}\n\t\t}\n\n\t\tif len(errs) == n {\n\t\t\treturn fmt.Errorf(\"unable to clear breakpoint %d: %v\", lbp.LogicalID, buf.String())\n\t\t}\n\t\treturn fmt.Errorf(\"unable to clear breakpoint %d (partial): %s\", lbp.LogicalID, buf.String())\n\t}\n\treturn nil\n}\n\n// ChangeBreakpointCondition changes the breakpoint condition of lbp.\nfunc (grp *TargetGroup) ChangeBreakpointCondition(lbp *LogicalBreakpoint, cond, hitCond string, hitCondPerG bool) error {\n\tlbp.cond = nil\n\tif cond != \"\" {\n\t\tvar err error\n\t\tlbp.cond, err = parser.ParseExpr(cond)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tt := ValidTargets{Group: grp}","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/target_group.go#L423-L459","documentation":"disableBreakpoint attempted to clear every physical breakpoint belonging to the logical breakpoint across all valid targets, and ALL of those clears failed (len(errs) == n). The individual errors are comma-joined into this single message, so the breakpoint remains set in every target.","triggerScenarios":"Calling SetBreakpointEnabled(lbp, false), ChangeBreakpointCondition, or manageUnsatisfiableBreakpoints when every ClearBreakpoint call fails — typically because the process memory cannot be read/written (process exited, crashed, or text page unavailable) while the target still reports as valid.","commonSituations":"Target crashed between stop and disable; breakpoint at an address in memory that was unmapped by exec/runtime; ptrace write failures after the debuggee died; disabling breakpoints during shutdown of a dead process.","solutions":["Read the joined sub-errors to identify the per-target failure reason","Check whether the target process is actually alive (it may have exited despite appearing valid)","If the process is dead, detach/kill the session instead of disabling breakpoints","Retry the disable after resuming or restarting the process","As a last resort, discard the session: the INT3 bytes die with the process"],"exampleFix":"// before\nerr := grp.SetBreakpointEnabled(lbp, false) // fails: process already exited\n// after\nok, _ := grp.Valid()\nif !ok {\n    return client.Detach(true) // process gone, tear down session\n}\nreturn grp.SetBreakpointEnabled(lbp, false)","handlingStrategy":"try-catch","validationCode":"ok, _ := grp.Valid()\nif !ok {\n    // all targets invalid; disable is meaningless, tear down instead\n    return nil\n}","typeGuard":"func isDisableErr(err error) bool {\n    return err != nil && strings.HasPrefix(err.Error(), \"unable to clear breakpoint \")\n}","tryCatchPattern":"if err := grp.SetBreakpointEnabled(lbp, false); err != nil {\n    if isDisableErr(err) {\n        // every clear failed: process likely dead; abort session instead of retrying\n        return grp.Detach(true)\n    }\n    return err\n}","preventionTips":["Confirm the debuggee is alive before mutating breakpoints (check State/Exited)","Handle process-exit events promptly so breakpoints are not disabled on dead processes","Keep session teardown ordered: resume/stop state first, then breakpoint changes","Log the joined sub-errors — they identify the exact memory/ptrace failure"],"tags":["go","debugger","breakpoint","clear-failed"],"backgroundTag":"breakpoint-clear-failed","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}