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
Neovim segfaults on termux when dismissing and raising onscreen keyboard #22278
Labels
bug-crash
issue reporting a crash or segfault
has:backtrace
issue contains a stacktrace/ASAN log
has:repro
issue contains minimal reproducing steps
ui
Milestone
Comments
The terminal dimensions where I get segfaults are 35 cols × 14 lines, or 33 cols × 13 lines. |
Backtrace:
ASAN log:
|
zeertzjq
added
ui
has:backtrace
issue contains a stacktrace/ASAN log
bug-crash
issue reporting a crash or segfault
and removed
bug
issues reporting wrong behavior
labels
Feb 16, 2023
Script to reproduce: vim.fn.termopen({ vim.v.progpath, '-u', 'NONE', '-i', 'NONE', '-c', 'set linebreak' })
vim.defer_fn(function()
vim.fn.jobresize(vim.bo.channel, 35, 14)
vim.defer_fn(function()
vim.fn.chansend(vim.bo.channel, 'i' .. [[
x xxx xxxxxxxx xx xxx xxx xxxxxx xxxx x xxxxx xxx xxxxxxx x xxx xxxx xxxxxx xxx xxxxxxxxxx xxxxx xxxxx xx xxxxxx xxx xx xxxxxx
xxxxx xxxxx xxxxx xx xxxxx xxxxxx xx xxxxx xxxxxxx xxx xxxxxx xx xxxxx xxxx xxxx xxxxxx xxxx xxxx xxxxxx xx xxxxxx xxxx xx xxx xxxx xxxxx xxxxx xxxx xxxxx xxxxxxxx xx xx xxxxx xxxx xxxxx xxxx xxxxxxxxx xx xxxx xxx xxxxx xxx xxxx xxx xxxxx xxxx xx xxxxxx xxx xxxx xxxx xxx xxxx xxxx xx xxxx xxxxx x xxxx xxx xxxxx xxxxxxxxxxxxx x xxxxxxxxxxxxxxx xxxxxxx x xxxxx xxxxx x xxx xxxxxx xx xxxxxxxx xxxx xxxxx]] .. '\027')
vim.defer_fn(function()
vim.fn.jobresize(vim.bo.channel, 35, 21)
vim.defer_fn(function()
vim.fn.jobresize(vim.bo.channel, 35, 13)
end, 1000)
end, 1000)
end, 1000)
end, 1000) |
This seems to fix the problem: diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index 0ac522059..f392477f4 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -232,6 +232,7 @@ void screenclear(void)
if (wp->w_floating) {
wp->w_redr_type = UPD_CLEAR;
}
+ win_grid_alloc(wp);
}
if (must_redraw == UPD_CLEAR) {
must_redraw = UPD_NOT_VALID; // no need to clear again |
Test case: it('', function()
screen:try_resize(35, 14)
command('set laststatus=2 linebreak')
insert([[
x xxx xxxxxxxx xx xxx xxx xxxxxx xxxx x xxxxx xxx xxxxxxx x xxx xxxx xxxxxx xxx xxxxxxxxxx xxxxx xxxxx xx xxxxxx xxx xx xxxxxx
xxxxx xxxxx xxxxx xx xxxxx xxxxxx xx xxxxx xxxxxxx xxx xxxxxx xx xxxxx xxxx xxxx xxxxxx xxxx xxxx xxxxxx xx xxxxxx xxxx xx xxx xxxx xxxxx xxxxx xxxx xxxxx xxxxxxxx xx xx xxxxx xxxx xxxxx xxxx xxxxxxxxx xx xxxx xxx xxxxx xxx xxxx xxx xxxxx xxxx xx xxxxxx xxx xxxx xxxx xxx xxxx xxxx xx xxxx xxxxx x xxxx xxx xxxxx xxxxxxxxxxxxx x xxxxxxxxxxxxxxx xxxxxxx x xxxxx xxxxx x xxx xxxxxx xx xxxxxxxx xxxx xxxxx]])
screen:try_resize(35, 21)
screen:try_resize(35, 13)
assert_alive()
end) |
The solution above doesn't work for the case where there is a more prompt: vim.fn.termopen({ vim.v.progpath, '-u', 'NONE', '-i', 'NONE', '-c', 'set linebreak' })
vim.defer_fn(function()
vim.fn.jobresize(vim.bo.channel, 35, 14)
vim.defer_fn(function()
vim.fn.chansend(vim.bo.channel, 'i' .. [[
x xxx xxxxxxxx xx xxx xxx xxxxxx xxxx x xxxxx xxx xxxxxxx x xxx xxxx xxxxxx xxx xxxxxxxxxx xxxxx xxxxx xx xxxxxx xxx xx xxxxxx
xxxxx xxxxx xxxxx xx xxxxx xxxxxx xx xxxxx xxxxxxx xxx xxxxxx xx xxxxx xxxx xxxx xxxxxx xxxx xxxx xxxxxx xx xxxxxx xxxx xx xxx xxxx xxxxx xxxxx xxxx xxxxx xxxxxxxx xx xx xxxxx xxxx xxxxx xxxx xxxxxxxxx xx xxxx xxx xxxxx xxx xxxx xxx xxxxx xxxx xx xxxxxx xxx xxxx xxxx xxx xxxx xxxx xx xxxx xxxxx x xxxx xxx xxxxx xxxxxxxxxxxxx x xxxxxxxxxxxxxxx xxxxxxx x xxxxx xxxxx x xxx xxxxxx xx xxxxxxxx xxxx xxxxx]] .. '\027')
vim.defer_fn(function()
vim.fn.jobresize(vim.bo.channel, 35, 21)
vim.defer_fn(function()
vim.fn.chansend(vim.bo.channel, ':hi\r')
vim.defer_fn(function()
vim.fn.jobresize(vim.bo.channel, 35, 13)
vim.defer_fn(function()
vim.fn.chansend(vim.bo.channel, 'q')
end, 1000)
end, 1000)
end, 1000)
end, 1000)
end, 1000)
end, 1000) |
This fixes the case above: diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index 0ac522059..3760e4256 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -306,6 +306,10 @@ void screen_resize(int width, int height)
RedrawingDisabled--;
+ FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
+ win_grid_alloc(wp);
+ }
+
// Do not apply autocommands more than 3 times to avoid an endless loop
// in case applying autocommands always changes Rows or Columns.
if (++retry_count > 3) { |
This crash can also apply to windows in another tabpage: it('', function()
screen:try_resize(35, 14)
command('set laststatus=2 linebreak')
insert([[
x xxx xxxxxxxx xx xxx xxx xxxxxx xxxx x xxxxx xxx xxxxxxx x xxx xxxx xxxxxx xxx xxxxxxxxxx xxxxx xxxxx xx xxxxxx xxx xx xxxxxx
xxxxx xxxxx xxxxx xx xxxxx xxxxxx xx xxxxx xxxxxxx xxx xxxxxx xx xxxxx xxxx xxxx xxxxxx xxxx xxxx xxxxxx xx xxxxxx xxxx xx xxx xxxx xxxxx xxxxx xxxx xxxxx xxxxxxxx xx xx xxxxx xxxx xxxxx xxxx xxxxxxxxx xx xxxx xxx xxxxx xxx xxxx xxx xxxxx xxxx xx xxxxxx xxx xxxx xxxx xxx xxxx xxxx xx xxxx xxxxx x xxxx xxx xxxxx xxxxxxxxxxxxx x xxxxxxxxxxxxxxx xxxxxxx x xxxxx xxxxx x xxx xxxxxx xx xxxxxxxx xxxx xxxxx]])
screen:try_resize(35, 21)
command('tabnew')
screen:try_resize(35, 13)
exec_lua([[
vim.cmd.tabprev()
vim.wo.signcolumn = 'yes'
]])
assert_alive()
end) So the fix above isn't the correct fix either. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug-crash
issue reporting a crash or segfault
has:backtrace
issue contains a stacktrace/ASAN log
has:repro
issue contains minimal reproducing steps
ui
Describe the bug
If I open a particular file in neovim, scroll to the very last line, dismiss the onscreen keyboard, and then pull the keyboard back up again, neovim segfaults. Consistently. I eliminated my configs as a cause.
I haven't been able to reproduce this on a PC, because I don't know what would have the equivalent effect of raising and lowering a onscreen keyboard. I don't yet know if neovim or termux or both are responsible.
It looks like the bug is caused by the last line being wrapped and partially offscreen. So your terminal dimensions have to allow that.
Steps to reproduce
Use the onscreen keyboard for this.
curl -s https://termbin.com/2q2fq | nvim -u NONE -c "set linebreak"
G$
(move the cursor to the end of the last line in the file)Expected behavior
It shouldn't segfault.
Neovim version (nvim -v)
0.8.3
Vim (not Nvim) behaves the same?
no, vim 9.0
Operating system/version
Android 10
Terminal name/version
termux 0.118.0
$TERM environment variable
xterm-256color
Installation
system package manager (the
pkg
command in termux)EDIT: Added terminal sizes to "steps to reproduce".
The text was updated successfully, but these errors were encountered: