Steps to reliably reproduce the problem here:
set tw=0
set wrap
go to insert mode in a new buffer (any file/buffer will do)
keep spacebar (or any other character on the keyboard) pressed, so it repeats somewhat quickly
depending on the VimR window size, when hitting the right border of the window (just before it should wrap), VimR crashes with:
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [0]
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.qvacua.VimR.SwiftNeoVim 0x000000010822cdc7 specialized Grid.put(_:) + 615
1 com.qvacua.VimR.SwiftNeoVim 0x000000010823741c specialized closure #1 in NeoVimView.put(_:) + 92
2 com.qvacua.VimR.SwiftNeoVim 0x00000001082361fc partial apply for closure #1 in NeoVimView.put(_:) + 76
3 libdispatch.dylib 0x00007fff5dd1b7a2 _dispatch_call_block_and_release + 12
4 libdispatch.dylib 0x00007fff5dd13f64 _dispatch_client_callout + 8
5 libdispatch.dylib 0x00007fff5dd1f545 _dispatch_main_queue_callback_4CF + 1148
6 com.apple.CoreFoundation 0x00007fff36789a09 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
7 com.apple.CoreFoundation 0x00007fff3674c2ba __CFRunLoopRun + 2586
8 com.apple.CoreFoundation 0x00007fff3674b607 CFRunLoopRunSpecific + 487
9 com.apple.HIToolbox 0x00007fff35a60866 RunCurrentEventLoopInMode + 286
10 com.apple.HIToolbox 0x00007fff35a605d6 ReceiveNextEventCommon + 613
11 com.apple.HIToolbox 0x00007fff35a60354 _BlockUntilNextEventMatchingListInModeWithFilter + 64
12 com.apple.AppKit 0x00007fff33d5d9f7 _DPSNextEvent + 2085
13 com.apple.AppKit 0x00007fff344f2d98 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 3044
14 com.apple.AppKit 0x00007fff33d52805 -[NSApplication run] + 764
15 com.apple.AppKit 0x00007fff33d219a6 NSApplicationMain + 804
16 com.qvacua.VimR 0x0000000107e1f369 main + 9
17 libdyld.dylib 0x00007fff5dd4d145 start + 1
It does not crash reliably when typing text slowly.
Affected: Version 0.19.0 (226)
I have to correct that. Issue is similar to #431, but happens without any plugins. Actually
set list
must be active, but the crash happends independ of the used set listchar.
It will crash when a whole line of text only shows the trail listchar, just before wrapping onto the next line. It actually happens independ of typing speed (which makes sense).
Hope that makes it easier to reproduce.
A workaround is set nolist.
red herring. It still crashes as before (when wrap is enabled). Any idea how to debug this and track it down to a specific setting in my init.vim?
worth noting, it does not crash when the insert cursor is not behind the last character on the current line. It only crashes during wrapping when doing A-like appending to the end of line.
It's crashing in the self.cells line of
func put(_ string: String) {
// FIXME: handle the following situation:
// |abcde | <- type γ
// =>
// |abcde>| <- ">" at the end of the line is wrong -> the XPC could tell the main app whether the string occupies
// |γ
| two cells using vim_strwidth()
self.cells[self.position.row][self.position.column] = Cell(string: string, attrs: self.attrs)
// Increment the column of the put position because neovim calls sets the position only once when drawing
// consecutive cells in the same line
self.advancePosition()
}
with fatal error: Index out of range (lldb)
in VimR => SwiftNeoVim => Grid.swift => put()
Hope that helps to get it fixed. With set tw=0 it seems I cannot find a workaround to prevent the crash.
Fixes the symptom by avoiding the one-off issue (until we got a better solution):
diff --git a/SwiftNeoVim/Grid.swift b/SwiftNeoVim/Grid.swift
index e6d90e03..e9dea59e 100644
--- a/SwiftNeoVim/Grid.swift
+++ b/SwiftNeoVim/Grid.swift
@@ -78,11 +78,14 @@ struct Region: CustomStringConvertible {
}
var rowRange: CountableClosedRange<Int> {
- return self.top...self.bottom
+ return self.top...self.bottom;
}
var columnRange: CountableClosedRange<Int> {
- return self.left...self.right
+ if (self.right >= self.left){
+ return self.left...self.right;
+ }
+ return self.right...self.left;
}
}
@@ -120,7 +123,7 @@ class Grid: CustomStringConvertible {
let emptyCellAttrs = CellAttributes(fontTrait: .none,
foreground: self.foreground, background: self.background, special: self.special)
- let emptyRow = Array(repeating: Cell(string: " ", attrs: emptyCellAttrs), count: size.width)
+ let emptyRow = Array(repeating: Cell(string: " ", attrs: emptyCellAttrs), count: size.width + 1)
self.cells = Array(repeating: emptyRow, count: size.height)
}
@@ -175,7 +178,7 @@ class Grid: CustomStringConvertible {
func put(_ string: String) {
// FIXME: handle the following situation:
- // |abcde | <- type γ
+ // |abcde | <- type γ
// =>
// |abcde>| <- ">" at the end of the line is wrong -> the XPC could tell the main app whether the string occupies
// |γ
| two cells using vim_strwidth()
diff --git a/neovim b/neovim
--- a/neovim
+++ b/neovim
@@ -1 +1 @@
-Subproject commit 4e22de4ec62102cd08cd1164133edd474881c817
+Subproject commit 4e22de4ec62102cd08cd1164133edd474881c817-dirty
I'll have look at it. Thanks for reporting and showing a possible fix! :)
Thank you for all the amazing work you are doing @qvacua! Just wanted to bring this to attention again as it's been a while since the last comment.
Please let me know if you need anything to help you with this issue! And thanks @kropper for extensive debugging.
thanks for bumping this one.
sadly, the problem still persists in the more recent releases of VimR, but the patch provided above, ugly as it may be, serves me as a sufficient workaround. Given that VimR is probably the best looking and performing neovim GUI on macOS, stability is somewhat important. :-)
I'm so sorry, (I think) I forgot to integrate it in a release. Will do.
Hm, I cannot reproduce this issue with only the two lines in init.vim. Is there a specific window size where it happens?
It does not depend on the window size.
It indeed is not reproducible with a vanilla init.vim ; as outlined in the above comments, I had tried to narrow down which setting is causing this problem exactly, but without success.
However, it my overall configuration, VimR (without my ugly patch) always crashes in the described situation, but neither TUI nvim nor any other neovim GUI crash. It seems like a classic one-off implementation error to me, as increasing the count parameter by 1 fixes the crash. However, columnRange then sometimes yields a negative number, which causes the next crash and lead to my ugly patch there. I have no knowledge about nvim'r and VimR's internal workings, but maybe the columnRange-thing gives you some clue about the situations where this can occur.
I've narrowed down which config was causing this issue for me. In my case indentLine plugin seems to be the culprit.
call plug#begin('~/.config/nvim/plugged')
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'rking/ag.vim'
Plug 'christoomey/vim-tmux-navigator'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'altercation/vim-colors-solarized'
" Plug 'Yggdroot/indentLine'
Plug 'bronson/vim-trailing-whitespace'
Plug 'tpope/vim-fugitive'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'elzr/vim-json'
Plug 'w0rp/ale'
call plug#end()
So I guess the workaround for this issue is to not load the plugin for gui vim
I don't have that plugin but it still crashes anyway.
However, the root cause might be a setting this plugin activates.
I'll investigate this further.
Could you, @ayohan and @kropper, post your init.vim? I could not reproduce it with Yggdroot/indentLine plugin...
let mapleader = ";"
set smartcase " Case insensitive search when text contains all lower case, case sensitive when they're not. Needs ignorecase to be set
set ignorecase " Case insensitive search
set wildignorecase " Case is ignored when completing file names and directories
"set termguicolors " this fucks up colors in tmux
colorscheme NeoSolarized
set background=dark
set clipboard+=unnamedplus " yank to clipboard
" auto reload file when it changes from outside
set autoread
au FocusGained * :checktime
" configs from http://nerditya.com/code/guide-to-neovim/
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set showmode " Show current mode.
set ruler " Show the line and column numbers of the cursor.
set number " Show the line numbers on the left side.
set formatoptions+=o " Continue comment marker in new lines.
set textwidth=0 " Hard-wrap long lines as you type them.
set expandtab " Insert spaces when TAB is pressed.
set tabstop=2 " Render TABs using this many spaces.
set shiftwidth=2 " Indentation amount for < and > commands.
set noerrorbells " No beeps.
set modeline " Enable modeline.
set linespace=0 " Set line-spacing to minimum.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set nostartofline " Do not jump to first character with page commands.
""
set mouse=a " Enable mouse interaction
" what i am used to
nnoremap <leader>w :w<CR>
nnoremap <leader>v <C-W>v
nnoremap <leader>s <C-W>s
nnoremap <leader>r <C-R>
nnoremap <leader>h :set hlsearch!<CR>
""
" cycle through buffers
:nnoremap <Tab> :bnext<CR>
:nnoremap <S-TAB> :bprevious<CR>
""
"controlP to fuzzy search
nnoremap <C-p> :FZF<CR>
" don't jump multiple lines for a long line
nmap j gj
nmap k gk
""
" paste on a new line
nmap <leader>p :pu<CR>
""
" map :Noh to :noh. I do this way too often
cnoreabbrev Noh noh
" pane navigation
nnoremap <silent> <c-j> :TmuxNavigateDown<cr>
nnoremap <silent> <c-k> :TmuxNavigateUp<cr>
nnoremap <silent> <c-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <c-l> :TmuxNavigateRight<cr>
nnoremap <silent> <c-p>p :TmuxNavigatePrevious<cr>
" bugfix for c-h
nnoremap <silent> <BS> :TmuxNavigateLeft<cr>
let g:tmux_navigator_no_mappings = 1
""
"JSX
let g:jsx_ext_required = 0 " allow jsx in js files
au BufNewFile,BufRead *.jsx set filetype=javascript.jsx " set filetype to jsx for files with fsx extension
""
"autocmd! BufWritePost * Neomake
" Nerdtree
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * wincmd p
let NERDTreeHighlightCursorline=1
let NERDTreeIgnore = ['tmp', '.yardoc', 'pkg', '\.git*','\.DS_Store$']
let NERDTreeShowHidden=1
let g:NERDTreeWinSize=45
let g:NERDTreeAutoDeleteBuffer=1
let g:NERDTreeDirArrowExpandable = 'β' "*
let g:NERDTreeDirArrowCollapsible = 'β' "|β‘
let g:NERDTreeWinSize=35
highlight NERDTreeOpenable ctermfg=Red guifg=#D33F3F " #d7d700
highlight NERDTreeClosable ctermfg=Red guifg=#D33F3F
nmap <leader>n :NERDTreeToggle<CR>
"" Nerdtree
" airline
let g:airline#extensions#tabline#enabled = 1 " Enable the list of buffers Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
let g:molokai_original = 1
let currentDirectory = toupper(fnamemodify(getcwd(), ':t'))
let g:airline_section_y = currentDirectory " change default git branch section to show app name
"" airline
" Indent lines
let g:indentLine_color_term = 239
let g:indentLine_char = 'Λ' "βΛ:ΛΈ
let g:indentLine_enabled = 1
"" Indent lines
let g:deoplete#enable_at_startup = 1 " Use deoplete.
let g:vim_json_syntax_conceal = 0 " show quotes in json files
" override default ALE error signs
let g:ale_sign_error = 'π₯'
let g:ale_sign_warning = 'π€'
" Plugins
call plug#begin('~/.config/nvim/plugged')
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'rking/ag.vim'
Plug 'christoomey/vim-tmux-navigator'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'altercation/vim-colors-solarized'
Plug 'Yggdroot/indentLine'
Plug 'bronson/vim-trailing-whitespace'
Plug 'tpope/vim-fugitive'
Plug 'pangloss/vim-javascript'
Plug 'mxw/vim-jsx'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'elzr/vim-json'
Plug 'w0rp/ale'
call plug#end()
"" toggle solarized light/dark
call togglebg#map("<leader>5")
develop - build works like a charm
Most helpful comment
I'll investigate this further.