8000 Fix: interrupting confirm() called in timer causes vim hang by ichizok · Pull Request #1791 · vim/vim · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix: interrupting confirm() called in timer causes vim hang #1791

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

Closed
wants to merge 1 commit into from

Conversation

ichizok
Copy link
Contributor
@ichizok ichizok commented Jun 23, 2017

repro steps

test-environments:

  • macOS 10.12.5, Terminal.app
  • Ubuntu 16.04, gnome-terminal

test.vim

fu! Test_timer(timer) abort
  call feedkeys('o')
  call confirm('?')
endfu
call timer_start(100, 'Test_timer')

vim -Nu NONE -S test.vim

and input Ctrl-C to interrupt confirm(), then vim will hang.

Note: input() also instead of confirm().

cause

preconditions:

  • confirm() and feedkeys() are called from timer fired in waiting for input (not in do_sleep())
  • confirm() isn't enclosed by try (i.e. exception isn't caught inside timer callback)

feedkeys() in timer sets typebuf_was_filled to TRUE, so typebuf_changed() returns TRUE,
but Ctrl-C flushes all input buffer and typebuf_was_filled is kept to TRUE, thus cannot exit from this loop: https://github.com/vim/vim/tree/06f1ed2f78c5c03af95054fc3a8665df39dec362/src/getchar.c#L2029

proposal of fix

  • Set typebuf_was_filled to FALSE in flush_buffers()
    (but but I'm not sure there is no side influence by this change...)

Ozaki Kiichi

* calling confirm() in timer in vgetc() (not in do_sleep())
* calling feedkeys() in timer
* and interrupt confirm() by Ctrl-C
@codecov-io
Copy link

Codecov Report

Merging #1791 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1791      +/-   ##
==========================================
- Coverage   75.08%   75.07%   -0.02%     
==========================================
  Files          76       76              
  Lines      125067   125072       +5     
==========================================
- Hits        93907    93897      -10     
- Misses      31160    31175      +15
Impacted Files Coverage Δ
src/getchar.c 73.8% <100%> (+0.01%) ⬆️
src/if_xcmdsrv.c 84.25% <0%> (-1.86%) ⬇️
src/os_unix.c 58.23% <0%> (-0.2%) ⬇️
src/ex_cmds2.c 79.6% <0%> (-0.11%) ⬇️
src/evalfunc.c 81.6% <0%> (-0.03%) ⬇️
src/version.c 80.3% <0%> (ø) ⬆️
src/userfunc.c 86.6% <0%> (ø) ⬆️
src/message.c 68.12% <0%> (+0.04%) ⬆️
src/gui_gtk_x11.c 47.54% <0%> (+0.05%) ⬆️
src/gui.c 45.64% <0%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4670490...fea62e2. Read the comment docs.

@brammool brammool closed this in 4eb6531 Jun 24, 2017
@ichizok ichizok deleted the fix/timer-confirm branch June 25, 2017 04:14
dpelle pushed a commit to dpelle/vim that referenced this pull request Jul 31, 2017
Problem:    When a function invoked from a timer calls confirm() and the user
            types CTRL-C then Vim hangs.
Solution:   Reset typebuf_was_filled. (Ozaki Kiichi, closes vim#1791)
janlazo added a commit to janlazo/neovim that referenced this pull request Jul 9, 2018
Problem:    When a function invoked from a timer calls confirm() and the user
            types CTRL-C then Vim hangs.
Solution:   Reset typebuf_was_filled. (Ozaki Kiichi, closes vim/vim#1791)
vim/vim@4eb6531
janlazo added a commit to janlazo/neovim that referenced this pull request Jul 9, 2018
Problem:    When a function invoked from a timer calls confirm() and the user
            types CTRL-C then Vim hangs.
Solution:   Reset typebuf_was_filled. (Ozaki Kiichi, closes vim/vim#1791)
vim/vim@4eb6531
janlazo added a commit to janlazo/neovim that referenced this pull request Jul 20, 2018
Problem:    When a function invoked from a timer calls confirm() and the user
            types CTRL-C then Vim hangs.
Solution:   Reset typebuf_was_filled. (Ozaki Kiichi, closes vim/vim#1791)
vim/vim@4eb6531
janlazo added a commit to janlazo/neovim that referenced this pull request Aug 5, 2018
Problem:    When a function invoked from a timer calls confirm() and the user
            types CTRL-C then Vim hangs.
Solution:   Reset typebuf_was_filled. (Ozaki Kiichi, closes vim/vim#1791)
vim/vim@4eb6531
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
0