Skip to content

Fix conhost clipboard handling bugs#16618

Merged
DHowett merged 1 commit intorelease-1.19from
dev/lhecker/fix-clipboard-bugs-1.19
Jan 30, 2024
Merged

Fix conhost clipboard handling bugs#16618
DHowett merged 1 commit intorelease-1.19from
dev/lhecker/fix-clipboard-bugs-1.19

Conversation

@lhecker
Copy link
Member

@lhecker lhecker commented Jan 30, 2024

conhost has 2 bugs related to clipboard handling:

  • Missing retry on OpenClipboard: When copying to the clipboard
    explorer.exe is very eager to open the clipboard and peek into it.
    I'm not sure why it happens, but I can see CFSDropTarget in the
    call stack. It uses COM RPC and so this takes ~20ms every time.
    That breaks conhost's clipboard randomly during ConsoleBench.
    During non-benchmarks I expect this to break during RDP.
  • Missing null-terminator check during paste: CF_UNICODETEXT is
    documented to be a null-terminated string, which conhost v2
    failed to handle as it relied entirely on GlobalSize.

Additionally, this changeset simplifies the HGLOBAL code slightly
by adding _copyToClipboard to abstract it away.

(cherry picked from commit 86c30bd)

conhost has 2 bugs related to clipboard handling:
* Missing retry on `OpenClipboard`: When copying to the clipboard
  explorer.exe is very eager to open the clipboard and peek into it.
  I'm not sure why it happens, but I can see `CFSDropTarget` in the
  call stack. It uses COM RPC and so this takes ~20ms every time.
  That breaks conhost's clipboard randomly during `ConsoleBench`.
  During non-benchmarks I expect this to break during RDP.
* Missing null-terminator check during paste: `CF_UNICODETEXT` is
  documented to be a null-terminated string, which conhost v2
  failed to handle as it relied entirely on `GlobalSize`.

Additionally, this changeset simplifies the `HGLOBAL` code slightly
by adding `_copyToClipboard` to abstract it away.

* `ConsoleBench` (#16453) doesn't fail randomly anymore ✅

(cherry picked from commit 86c30bd)
@lhecker lhecker requested a review from DHowett January 30, 2024 12:32
@github-actions

This comment was marked as off-topic.

@DHowett DHowett merged commit add1632 into release-1.19 Jan 30, 2024
@DHowett DHowett deleted the dev/lhecker/fix-clipboard-bugs-1.19 branch January 30, 2024 15:52
lhecker added a commit that referenced this pull request Feb 6, 2024
#16618 contained a bug which was fixed inbox. This ports the
changes to the OSS repo manually since the two slightly diverged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants