Skip to content

Prevent self-owned selection deadlock after paste - #2

Merged
c-wri merged 2 commits into
mainfrom
agent/1-daemon-liveness
Aug 20, 2026
Merged

Prevent self-owned selection deadlock after paste#2
c-wri merged 2 commits into
mainfrom
agent/1-daemon-liveness

Conversation

@c-wri

@c-wri c-wri commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Why

Repeated operations could leave the daemon alive but permanently non-responsive until restart, violating the bounded command-ready invariant from docs/architecture.md.

The escaped failure class was identified: after ClipReg restores a selection, ClipReg may itself be the current clipboard source. snapshot_current() already protects this boundary by cloning the held MIME object, because synchronously receiving ClipReg's own Wayland offer would require source_send() on the same single-threaded event loop. stable_snapshot_current() bypassed that boundary and called the raw offer-receive path directly, allowing a later paste to deadlock while snapshotting the restored clipboard.

What

  • Added a direct runtime lifecycle regression for a compositor-visible self-owned clipboard offer.
  • First checkpoint intentionally proved the escaped behavior on the current beta and in Ubuntu CI.
  • Corrective checkpoint routes stable snapshots through the existing snapshot_current() self-ownership boundary.
  • Added phase-only grab/paste diagnostics with operation ID, phase, status, and duration; clipboard payloads are never logged.
  • Wired the lifecycle regression into strict and sanitizer gates.

No new daemon, thread, watchdog, timing workaround, public command, config surface, or version bump is introduced.

Validation

Negative proof before the correction:

  • PR checkpoint e10179ee3ee1167eb7ef62a434247466da33faac failed make check in Ubuntu 24.04 CI at [8/12] runtime lifecycle regressions with stable snapshot rejected a self-owned selection.

Corrective automated proof:

  • Local canonical make check passed on the supported workstation checkout, including offline regressions, ASan/UBSan, real wayland-scanner, installed libwayland-client, and binary self-test.
  • Corrective checkpoint e445ee5e99d216ee2c9d42d3352eac049905cb46 passed GitHub CI / Check on Ubuntu 24.04.
  • CI also passed the tracked-state-clean verification.

Live COSMIC proof:

  • Pop!_OS 24.04 / COSMIC Terminal (com.system76.CosmicTerm).
  • 39 traced grab/paste operations in the captured journal window.
  • Repeated operations exercised snapshot-clipboard-clone-owned and snapshot-primary-clone-owned after restored selections.
  • Multiple terminal-grab failures returned bounded ETIMEDOUT results through transaction-finish; later operations remained command-ready.
  • NRestarts remained 0 -> 0.
  • Post-loop clipreg list, clipreg doctor, and clipreg app all responded successfully.
  • The prior alive-but-permanently-unusable state did not recur.

Release impact

The liveness blocker in issue #1 is satisfied by this candidate and may close when this PR is integrated. No prerelease is cut for this PR.

Two separate terminal behavior defects exposed by the same qualification remain blockers for v0.2.0-rc.1: #5 (generic Copy probe can leak terminal escape sequences) and #6 (clipboard-only paste unnecessarily disturbs primary-selection affinity).

Open / deferred

Exercise stable_snapshot_current() with a compositor-visible self-owned clipboard offer so validation fails if the daemon tries to synchronously receive its own selection instead of cloning held MIME data. Run the lifecycle regression in strict and sanitizer gates.
Route stable snapshots through the existing self-owned source boundary so restored ClipReg selections are cloned from held MIME data instead of synchronously requested through the same Wayland event loop. Add phase-only grab/paste tracing so future bounded-liveness failures expose their last transaction phase without logging clipboard payloads.
@c-wri c-wri added bug Something is not working area:runtime Native daemon, protocol, transaction, or persistence behavior release:0.2 Targets the v0.2.0 line labels Aug 20, 2026 — with ChatGPT Codex Connector
@c-wri c-wri added the priority:blocker Blocks the next release promotion label Aug 20, 2026 — with ChatGPT Codex Connector
@c-wri
c-wri marked this pull request as ready for review August 20, 2026 19:51
@c-wri
c-wri merged commit 7201ef3 into main Aug 20, 2026
1 check passed
@c-wri
c-wri deleted the agent/1-daemon-liveness branch August 20, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:runtime Native daemon, protocol, transaction, or persistence behavior bug Something is not working priority:blocker Blocks the next release promotion release:0.2 Targets the v0.2.0 line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant