Prevent self-owned selection deadlock after paste - #2
Merged
Conversation
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
marked this pull request as ready for review
August 20, 2026 19:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 requiresource_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
snapshot_current()self-ownership boundary.No new daemon, thread, watchdog, timing workaround, public command, config surface, or version bump is introduced.
Validation
Negative proof before the correction:
e10179ee3ee1167eb7ef62a434247466da33faacfailedmake checkin Ubuntu 24.04 CI at[8/12] runtime lifecycle regressionswithstable snapshot rejected a self-owned selection.Corrective automated proof:
make checkpassed on the supported workstation checkout, including offline regressions, ASan/UBSan, realwayland-scanner, installedlibwayland-client, and binary self-test.e445ee5e99d216ee2c9d42d3352eac049905cb46passed GitHubCI / Checkon Ubuntu 24.04.Live COSMIC proof:
com.system76.CosmicTerm).snapshot-clipboard-clone-ownedandsnapshot-primary-clone-ownedafter restored selections.ETIMEDOUTresults throughtransaction-finish; later operations remained command-ready.NRestartsremained0 -> 0.clipreg list,clipreg doctor, andclipreg appall responded successfully.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