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

Race condition in SIGWINCH handling #424

Open
joshtriplett opened this issue Sep 17, 2015 · 3 comments
Open

Race condition in SIGWINCH handling #424

joshtriplett opened this issue Sep 17, 2015 · 3 comments

Comments

@joshtriplett
Copy link

vim catches SIGWINCH and sets a resize flag. However, vim uses select(), rather than pselect() or ppoll(), so another SIGWINCH could happen again while vim handles the first resize. As a result, if two quick resizes with SIGWINCHes occur in a row, vim may not notice the second size change, and may remain at the first size.

vim should block SIGWINCH, and use pselect() or ppoll() to atomically unblock it while waiting for an event.

This came up in the context of https://bugzilla.gnome.org/show_bug.cgi?id=731137 in gnome-terminal.

@nfnty
Copy link

nfnty commented May 6, 2016

Any progress on this issue?

@dlitz
Copy link

dlitz commented Nov 19, 2022

I'm running into this with Konsole when using split views. Whenever I change focus between the views, Konsole performs two window-size changes in rapid succession.

[0.000] Got SIGWINCH; TIOCGWINSZ -> struct_winsize(ws_row=42, ws_col=93, ws_xpixel=930, ws_ypixel=892)
[0.003] Got SIGWINCH; TIOCGWINSZ -> struct_winsize(ws_row=41, ws_col=93, ws_xpixel=930, ws_ypixel=868)

Vim often loses the second resize, and attempts to draw the screen too big, resulting in terminal corruption shortly thereafter.

Edit: Actually, I think my issue is a separate bug where handle_resize() gets called recursively, which returns without doing any work because set_shellsize is busy. The select() race would cause a delay in performing the resize, but it shouldn't cause the resize event to be forgotten entirely.

brammool added a commit that referenced this issue Nov 22, 2022
Problem:    Second SIGWINCH signal may be ignored.
Solution:   When set_shellsize() is busy when called then run the inner code
            again when it's done.  (issue #424)
@brammool
Copy link
Contributor

Please try out with patch 9.0.0923 and see if this problem no longer occurs.

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

No branches or pull requests

4 participants