Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misbehaving applications can lock up xclip #34

Open
Narthorn opened this issue May 18, 2017 · 4 comments · May be fixed by #88
Open

Misbehaving applications can lock up xclip #34

Narthorn opened this issue May 18, 2017 · 4 comments · May be fixed by #88

Comments

@Narthorn
Copy link

When an xclip-owned selection has enough data to trigger the use of the INCR protocol when transferring, and an application that doesn't implement the INCR protocol requests clipboard data, xclip will enter the XCLIB_XCIN_INCR state, and then wait forever for the application to delete the INCR property, which will never happen.

While in that state, SelectionRequest events from other applications are not processed, and so the clipboard data becomes inaccessible: any application that tries to access the selection will freeze, waiting forever for a SelectionNotify event from xclip.

In my case, this bug was triggered by fcitx automatically grabbing the contents of the clipboard and locking up xclip whenever I tried to xclip -i something larger than 1MB, like a big enough screenshot. Killing fcitx let the clipboard work as expected, but I don't think a misbehaving application should be allowed to lock up xclip in the first place.

I'm not sure what the best solution would be for this ; I have an ugly fix here which "solves" the problem by just not caring about state at all and always responding to SelectionNotify events. That works well enough for me, but it is still pretty fragile (what happens if two applications request data at the same time?)...

Ideally, xclip should keep track of every INCR transfer separately so that it can still serve clipboard data while it's waiting for another INCR transfer to complete, but i'm not familiar enough with the code to actually implement that.

@astrand
Copy link
Owner

astrand commented May 23, 2017

Thanks for the report. It is probably possible to deal with this situation better. However, to be honest, I lack the knowledge how it should be, and the time to research. It might be useful to check what other applications and toolkits does, though.

@zatherz
Copy link

zatherz commented Aug 10, 2017

Just spent a day debugging this issue (trying to run xclip/xsel from inside a Unity3D game).

@ljrk0
Copy link

ljrk0 commented Sep 3, 2020

Closing stdout and stderr when running xclip with >&- 2>&- seems to do the trick.

@hackerb9
Copy link
Collaborator

hackerb9 commented Nov 5, 2020

If pull request #88 is merged, I believe this bug can be closed.

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 a pull request may close this issue.

5 participants