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

TUI: block signals on suspend (avoid kernel panic #8075) #12180

Merged
merged 1 commit into from
Apr 26, 2020

Conversation

Code-Hex
Copy link
Contributor

@Code-Hex Code-Hex commented Apr 25, 2020

This is only temporary, but it seems that kernel panic was occurring when sending signals to race when suspending, so I created a PR to fix it. #8075

I tried on macOS 10.14.5(18F132)
Terminal.app, iTerm2 (Build 3.3.9), bash 5.0, bash 3.2, zsh 5.7.1

@Code-Hex Code-Hex changed the title added blocking the signal when in suspend added blocking the signal when in suspend (avoid kernel panic #8075) Apr 25, 2020
@justinmk justinmk changed the title added blocking the signal when in suspend (avoid kernel panic #8075) block signals on suspend (avoid kernel panic #8075) Apr 26, 2020
@justinmk justinmk changed the title block signals on suspend (avoid kernel panic #8075) TUI: block signals on suspend (avoid kernel panic #8075) Apr 26, 2020
@justinmk
Copy link
Member

Nice, thank you!

This is only temporary

you mean, because we will switch to coprocesses instead of threads?

@justinmk justinmk added the tui label Apr 26, 2020
@justinmk justinmk merged commit c5217c6 into neovim:master Apr 26, 2020
justinmk pushed a commit that referenced this pull request Apr 26, 2020
@justinmk justinmk added this to the 0.4.4 milestone Apr 26, 2020
@Code-Hex
Copy link
Contributor Author

Code-Hex commented Apr 26, 2020

@justinmk Currently, the kernel panic actions (ctrl-z, ctrl -d, ctrl -d) do not perform the exit process that should have been done. I think it's the right way to call preserve_exit when exiting by any signals.

Looking back on this action.

1. ctrl-z => this will be handled by neovim and go to suspend state
2. ctrl-d => handled by shell and warned that there are still suspend processes (`you have suspended jobs.`).
3. ctrl-d => handled by shell. then the shell is terminated and some child processes are received signal to exit (zsh: SIGHUP, bash: SIGTERM)

I put a lot of logs in suspend_event and found out that after the execution of 3, two handlers, one for SIGCONT and one for EXIT SIGNAL (deadly_signal), were executed and entered the race state.

I don't think the SIGCONT handler should be executed in this case.

So, I think it's really necessary to process each received signal one by one, using mutual processing or event queues.

I believe this fix is only temporary in the meantime.

This is only temporary

I think there is probably a problem between

stream_set_blocking(input_global_fd(), false);
CONTINUE(data->bridge);

in suspend_event function and some functions in the exit process.

@Code-Hex
Copy link
Contributor Author

I also looked at syscalls called, so I put a log of those as well. I think the part after "kill" is the relevant part. (Please search for "kill.")
https://gist.github.com/Code-Hex/1f987ea46db24d2898aeec281f0ca2cf

jamessan added a commit that referenced this pull request Aug 5, 2020
Maintenance release for v0.4.x series.

FIXES:

fd02e63 #12701 ui: fix problem with sattr_T overflow
3e3002b #12710 fs: Ensure FileInfo struct is initialized
e4629f2 #12496 main.c: fix hang issue with recoverymode #12520
f558af8 #12209 fixed hang issue with --headless and -r option specified
cda1190 #12180 TUI: block signals on suspend
8399f73 #12142 Fix issues revealed by gcc10 setting -fno-common by default
5e47cf2 netrw.vim: do not save +/* registers
5d41bfc #11907 quickfix.c: Fix vimgrep regression
641e229 #11903 screen: add missing redraws after a message
47bd62c loop_close: close all handles
d273036 loop_close: call uv_stop(), fix bug
284b398 #11821 loop_close: timout after 2 seconds
1b2666c messages: echo "line1\r\nline2" should not clear line1
1bf90bf #11651 API: fix crash on copy_object(kObjectTypeWindow)
fafd636 #11566 libcallnr: Use int, not int64_t, as the return type for Vim compat
972dd75 #11460 win_line: Fix crash with 'rightleft' in :terminal
4c48cf3 f_getenv/setenv: Access v_special when v_type is VAR_SPECIAL
2cd1ff7 #11360 paste: Select-mode, Visual-mode
qvacua added a commit to qvacua/neovim that referenced this pull request Aug 12, 2020
NVIM v0.4.4

Maintenance release for v0.4.x series.

FIXES:

fd02e63 neovim#12701 ui: fix problem with sattr_T overflow
3e3002b neovim#12710 fs: Ensure FileInfo struct is initialized
e4629f2 neovim#12496 main.c: fix hang issue with recoverymode neovim#12520
f558af8 neovim#12209 fixed hang issue with --headless and -r option specified
cda1190 neovim#12180 TUI: block signals on suspend
8399f73 neovim#12142 Fix issues revealed by gcc10 setting -fno-common by default
5e47cf2 netrw.vim: do not save +/* registers
5d41bfc neovim#11907 quickfix.c: Fix vimgrep regression
641e229 neovim#11903 screen: add missing redraws after a message
47bd62c loop_close: close all handles
d273036 loop_close: call uv_stop(), fix bug
284b398 neovim#11821 loop_close: timout after 2 seconds
1b2666c messages: echo "line1\r\nline2" should not clear line1
1bf90bf neovim#11651 API: fix crash on copy_object(kObjectTypeWindow)
fafd636 neovim#11566 libcallnr: Use int, not int64_t, as the return type for Vim compat
972dd75 neovim#11460 win_line: Fix crash with 'rightleft' in :terminal
4c48cf3 f_getenv/setenv: Access v_special when v_type is VAR_SPECIAL
2cd1ff7 neovim#11360 paste: Select-mode, Visual-mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants