Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

E315: ml_get: invalid lnum: 32 #112

Closed
antonvesnin opened this issue Feb 1, 2016 · 30 comments
Closed

E315: ml_get: invalid lnum: 32 #112

antonvesnin opened this issue Feb 1, 2016 · 30 comments
Assignees

Comments

@antonvesnin
Copy link

When I open a few C files in gvim, and switch between different buffers few times, after a little bit i'm getting this error and syntax coloring breaks. If I reopen the file, syntax coloring goes back, but after a few buffer switching i'm getting the same problem. :CCerror says there is no error, unfortunatly I don't know how to get more debug information for this case, E315 as I know it vim's internal error, but if i disable color coded even by :CCtoggle the error goes away. I use vim compiled from git, let me know if I can provide any more useful information. This always reopening a file is pretty annoying.

@jeaye
Copy link
Owner

jeaye commented Feb 2, 2016

That's an error I've never seen. Mind sharing some more info about your OS, lua version, and vim version (macvim, vim-gtk, vim-qt, terminal, etc)

@jeaye jeaye self-assigned this Feb 2, 2016
@antonvesnin
Copy link
Author

Here is my vim --version output, used on ubuntu 15.10 x86_64

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb  2 2016 12:47:26)
Included patches: 1-1236
Compiled by freeman@najaf
Huge version with GTK2-GNOME GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_sgr       +tag_old_static
+arabic          +file_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +find_in_path    +mouse_urxvt     -tcl
+balloon_eval    +float           +mouse_xterm     +terminfo
+browse          +folding         +multi_byte      +termresponse
++builtin_terms  -footer          +multi_lang      +textobjects
+byte_offset     +fork()          -mzscheme        +title
+channel         +gettext         -netbeans_intg   +toolbar
+cindent         -hangul_input    +path_extra      +user_commands
+clientserver    +iconv           +perl            +vertsplit
+clipboard       +insert_expand   +persistent_undo +virtualedit
+cmdline_compl   +jumplist        +postscript      +visual
+cmdline_hist    +keymap          +printer         +visualextra
+cmdline_info    +langmap         +profile         +viminfo
+comments        +libcall         +python          +vreplace
+conceal         +linebreak       -python3         +wildignore
+cryptv          +lispindent      +quickfix        +wildmenu
+cscope          +listcmds        +reltime         +windows
+cursorbind      +localmap        +rightleft       +writebackup
+cursorshape     +lua             +ruby            +X11
+dialog_con_gui  +menu            +scrollbind      -xfontset
+diff            +mksession       +signs           +xim
+digraphs        +modify_fname    +smartindent     +xsmp_interact
+dnd             +mouse           -sniff           +xterm_clipboard
-ebcdic          +mouseshape      +startuptime     -xterm_save
+emacs_tags      +mouse_dec       +statusline      +xpm
+eval            -mouse_gpm       -sun_workshop    
+ex_extra        -mouse_jsbterm   +syntax          
+extra_search    +mouse_netterm   +tag_binary      
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
 f-b for $VIMRUNTIME: "/usr/share/vim/vim74"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/freetype2  -D_REENTRANT -DORBIT2=1 -pthread -I/usr/include/libgnomeui-2.0 -I/usr/include/gnome-keyring-1 -I/usr/include/libbonoboui-2.0 -I/usr/include/libxml2 -I/usr/include/libgnome-2.0 -I/usr/include/libbonobo-2.0 -I/usr/include/bonobo-activation-2.0 -I/usr/include/orbit-2.0 -I/usr/include/libgnomecanvas-2.0 -I/usr/include/gail-1.0 -I/usr/include/libart-2.0 -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/gnome-vfs-2.0 -I/usr/lib/x86_64-linux-gnu/gnome-vfs-2.0/include -I/usr/include/gconf/2 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include    -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/ruby2.1-_3OTYb/ruby2.1-2.1.5/debian/lib -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lfontconfig -lfreetype   -lgnomeui-2 -lSM -lICE -lbonoboui-2 -lgnome-2 -lpopt -lbonobo-2 -lbonobo-activation -lORBit-2 -lgnomecanvas-2 -lart_lgpl_2 -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lfontconfig -lfreetype -lgdk_pixbuf-2.0 -lgnomevfs-2 -lgconf-2 -lgthread-2.0 -lgmodule-2.0 -lgobject-2.0 -lglib-2.0  -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lelf -lnsl  -lselinux  -ldl  -L/usr/lib -llua5.2 -Wl,-E  -fstack-protector -L/usr/local/lib  -L/usr/lib/x86_64-linux-gnu/perl/5.20/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions   -lruby-2.1 -lpthread -lgmp -ldl -lcrypt -lm 

To reproduce i need just open 2 or more files and fast switch buffers between them (bind :bnext on C-tab or somewhere else). A few switches is enough. Maybe it has something to do with redrawing buffer content with highlighting? Does vim redraw in on every switch? It's just an ideda, but why else buffer switching will have something to do with color_coded?

@crashmaster
Copy link

Hello!

I experience this issue as well (editing 5 c files and switching between them with :bn or :bp):
E315: ml_get: invalid lnum: 2

Environment:
Ubuntu 14.04.3 LTS
Terminal: rxvt-unicode-256color 9.19-1
vim (just compiled, the system wide one was not fresh enough for color_coded):

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb  2 2016 12:25:29)
Included patches: 1-1236
Compiled by foobar@elxhqgld12-zk
Huge version without GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_sgr       +tag_old_static
+arabic          +file_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +find_in_path    +mouse_urxvt     -tcl
-balloon_eval    +float           +mouse_xterm     +terminfo
-browse          +folding         +multi_byte      +termresponse
++builtin_terms  -footer          +multi_lang      +textobjects
+byte_offset     +fork()          -mzscheme        +title
+channel         +gettext         -netbeans_intg   -toolbar
+cindent         -hangul_input    +path_extra      +user_commands
+clientserver    +iconv           -perl            +vertsplit
+clipboard       +insert_expand   +persistent_undo +virtualedit
+cmdline_compl   +jumplist        +postscript      +visual
+cmdline_hist    +keymap          +printer         +visualextra
+cmdline_info    +langmap         +profile         +viminfo
+comments        +libcall         +python/dyn      +vreplace
+conceal         +linebreak       +python3/dyn     +wildignore
+cryptv          +lispindent      +quickfix        +wildmenu
+cscope          +listcmds        +reltime         +windows
+cursorbind      +localmap        +rightleft       +writebackup
+cursorshape     +lua             -ruby            +X11
+dialog_con      +menu            +scrollbind      +xfontset
+diff            +mksession       +signs           -xim
+digraphs        +modify_fname    +smartindent     -xsmp
-dnd             +mouse           -sniff           +xterm_clipboard
-ebcdic          -mouseshape      +startuptime     -xterm_save
+emacs_tags      +mouse_dec       +statusline      -xpm
+eval            -mouse_gpm       -sun_workshop    
+ex_extra        -mouse_jsbterm   +syntax          
+extra_search    +mouse_netterm   +tag_binary      
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/home/foobar/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim    -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl    -ldl  -L/usr/lib -llua5.

@antonvesnin
Copy link
Author

Yes, the number after invalid lnum: may differ. I'm not shure what does it mean, i thought about some line number, but it changes from session to session, sometimes I got 32, sometimes 53, etc.

@cairijun
Copy link

Hey guys! The same issue happens to me from time to time on both Mac and Linux. I'm using the latest version of vim and lua from homebrew with default options on OSX 10.11.3. I guess there might be a conflict with one of my other plugins and I'm still digging into it. The following is a list of my installed plugins. May this be helpful to you.

Plugin 'VundleVim/Vundle.vim'
Plugin 'mileszs/ack.vim'
Plugin 'jeaye/color_coded'
Plugin 'tacahiroy/ctrlp-funky'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'rust-lang/rust.vim'
Plugin 'scrooloose/syntastic'
Plugin 'majutsushi/tagbar'
Plugin 'solarnz/thrift.vim'
Plugin 'SirVer/ultisnips'
Plugin 'mbbill/undotree'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'altercation/vim-colors-solarized'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'tpope/vim-fugitive'
Plugin 'airblade/vim-gitgutter'
Plugin 'fisadev/vim-isort'
Plugin 'lervag/vim-latex'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'hynek/vim-python-pep8-indent'
Plugin 'honza/vim-snippets'
Plugin 'tpope/vim-surround'
Plugin 'rdnetto/YCM-Generator'
Plugin 'Valloric/YouCompleteMe'

@antonvesnin
Copy link
Author

Actually i tryed disabling ALL plugins, except NeoBundle and color_coded, and i still had this issue, so it's somewhere inside colorcoded. I'll be happy to provide more debugging info, just tell me how to do it, or what to check.

@alientechnology
Copy link

I confirm this issue too. Ubuntu 15.10 amd64, newest vim from git repo, tryid disabling all plugins except color_coded and the problem is still there. It must be somewhere in color_coded#enter() i sepose, but i'm not shure about that.

@UnrealQuester
Copy link
Collaborator

According to the vim help, E315 is an internal vim error.

  ml_get: invalid lnum: {number}

This is an internal Vim error.  Please try to find out how it can be
reproduced, and submit a bug report bugreport.vim.

I am unable to reproduce the error on my machine with my slightly older vim (Patches 1-1229). Maybe the bug was introduced recently?

@alientechnology
Copy link

@UnrealQuester

I am unable to reproduce the error on my machine with my slightly older vim (Patches 1-1229). Maybe the bug was introduced recently?

I don't think so. The reason I even started to build vim from source was this issue. So at least i had it in ubuntu 15.10 official vim from dist repo, i thought it will go away with newer vim but that never happend. And yes, it is vim's internal error, but it happens only if color_coded enabled, if I disable it even with :CCtoggle it goes away. And @crashmaster's vim is pretty old too, but he still has this issue.
@UnrealQuester, do you use your fork or color_coded from this repo?

@cairijun
Copy link

I think I've located it. I have the following two lines in my .vimrc and commenting them out perfectly solves the problem for me.

set foldmethod=syntax
set foldlevel=99

@alientechnology
Copy link

@richardtsai,

set foldmethod=syntax
set foldlevel=99

I don't have this or any other folding settings in my vimrc, but still having an issue, maybe you had some another settings, that helped? Anyone can confirm solving problem by this? I even tryed disabling folding by set nofoldenable and nothing changed.

@cairijun
Copy link

@alientechnology
do you have set hidden? enabling ether of these two setting works fine for me but not both of them.

@alientechnology
Copy link

@richardtsai, yes, I do have set hidden, could you be more specific, what exact settings with set hidden enabled worked for you? What is your foldmethod and foldlevel now? Thanks.

@cairijun
Copy link

works fine:

set hidden
" set foldmethod=syntax
" set foldlevel=99

works, but quite slow when jumping between buffers:

" set hidden
set foldmethod=syntax
set foldlevel=99

gets errors occasionally:

set hidden
set foldmethod=syntax
set foldlevel=99

@jeaye
Copy link
Owner

jeaye commented Feb 15, 2016

Thanks for working on this, guys. You mentioned folding is quite slow when switching buffers. In general, it will be slow when moving or typing, since Vim doesn't offer a good way to know if any given line is within a closed or open fold; it requires looking at every fold to determine where the line lies and whether or not that fold is open. As a result, color_coded adds highlighting for any collapsed folds within the current buffer; combined with Vim's awfully slow highlighting, this can drastically slow down Vim as a whole. There's not much I can do about that though.

As for this issue, I'm not yet sure if it's a Vim bug that color_coded is causing or some malpractice within color_coded that only shows up with these settings.

@alientechnology
Copy link

@richardtsai, interesting, disabling set hidden worked, but disabling folding didn't. Now i'm trying what will work with set hidden, because I need it.
@jeaye are you able to reproduce this problem? What information can we provide to be helpful?

@cairijun
Copy link

@alientechnology you can leave set hidden enabled and use binary search with comments to figure out which settings interfere with set hidden and color_coded. That's how I tracked down the folding settings.

@alientechnology
Copy link

@richardtsai that's what I just did, but didn't find anything, for now i think i have to leave without set hidden, I hope it'll be fixed soon.

@jeaye
Copy link
Owner

jeaye commented Feb 16, 2016

Have you guys seen https://github.com/critiqjo/lldb.nvim/issues/20?

@alientechnology
Copy link

@jeaye yeah, I saw this, when i googled our the error I got, but it's neovim, I don't know if it is related to our situatuion, anyway it dosen't look like they have any solutions for now. Maybe it should be addressed to vim developers too, but for this we need to know what at least viml or lua call creates this problem. I can't be shure, but it looks like I see this error mostly when I'm trying to swich from not saved buffer, maybe that's why set hidden! helps, but it's not always, sometimes even switching from saved buffer has same effect.

@alientechnology
Copy link

No, as i found later it has nothing to do with buffer being saved or not. I tried to run debug bn and see what is going on. Basicly I got something like this:

continuing in function color_coded#moved[7]..color_coded#add_match

line 2:   call add(g:color_coded_matches[s:file],matchaddpos(a:type, [[ a:line, a:col, a:len ]], -1))
line 4:   unlet s:file
function color_coded#moved[7]..color_coded#add_match returning #0

continuing in function color_coded#moved                                                                                                               

function color_coded#moved returning #0
continuing in CursorMoved Auto commands for "*"

E315: ml_get: invalid lnum: 42
E315: ml_get: invalid lnum: 42

And when there is no error, it's just

continuing in function color_coded#moved[7]..color_coded#add_match

line 2:   call add(g:color_coded_matches[s:file],matchaddpos(a:type, [[ a:line, a:col, a:len ]], -1))
line 4:   unlet s:file
function color_coded#moved[7]..color_coded#add_match returning #0

So maybe it has something to do with CursorMoved event, it's jsut a guess, but why it's even triggered on buffer switch?

@Hexcles
Copy link
Contributor

Hexcles commented Mar 3, 2016

I ran into this E315 ml_get error too. Disabling either color_coded or the built-in matchparen.vim (enabled by default) seems to be able to avoid the error. However, so far I can't find reliable ways to reproduce the bug. Hence, when I said "avoid the error", it might well be that the bug was still there but hadn't come up yet.

This is really a bizarre error and it seems to come from somewhere internal to vim. After a quick Google, apart from here in color_coded, this error has been reported in at least the following contexts:

@alientechnology
Copy link

Well for me reproducing is really easy. Open 3-4 buffers, do some :bnext - you'll see the error.
Unfortunatly I couldn't isolate problematic code in color_coded and create a minimal example, to report it to vims developers. If someone could isolate the problem, it would be very nice, i think they may help. As for me, i'm forced now either disable color_coded, or work without set hidden, and both are painful. I think there is some kind of race condition, and that's why it doesn't always easy to reproduce. And as i can see, at least in my case, disabling matchparen.vim doesn't help at all. I tryed both :NoMatchParen and setting let loaded_matchparen=1.

@UnrealQuester
Copy link
Collaborator

When switching buffers, vim will start highlighting the new buffer. Internally, vim holds a pointer to the buffer it wants to highlight as a global variable. Sometimes the pointer will not get updated. Vim then tries to iterate over the old buffer using the line count of the new buffer.

Does anyone want to try out this patch and see if this fixes it for them?

diff --git a/src/syntax.c b/src/syntax.c
index e37dacb..16dcb99 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -509,7 +509,7 @@ syntax_start(win_T *wp, linenr_T lnum)
      * Also do this when a change was made, the current state may be invalid
      * then.
      */
-    if (syn_block != wp->w_s || changedtick != syn_buf->b_changedtick)
+    if (syn_block != wp->w_s || changedtick != syn_buf->b_changedtick || wp->w_buffer != syn_buf)
     {
        invalidate_current_state();
        syn_buf = wp->w_buffer;

Tried with the newest git commit 014069a7ac51557e531eb3c8b94e36f2193f6c21

@alientechnology
Copy link

@UnrealQuester I just tried your patch with same newest commit, and I couldn't reproduce this problem anymore, so looks like it helps. I will do more testing tomorrow, but basicly before this patch i got E315 after just few bnext with set hidden enabled. You really should send a PR to vims developers.

@UnrealQuester
Copy link
Collaborator

@alientechnology Thank you for confirming that the fix works, your help is highly appreciated. I will open up a PR for that. But first I need to look into the issue a bit more. git blame tells me that the check was there in 2010 but got removed with the conceal patch. This migth be just a workaround for a different issue higher up the call chain.

@alientechnology
Copy link

@UnrealQuester at least what I can see, conceal still works, i use some stuff like syntax keyword lispConcealLambda lambda conceal cchar=λ for common lisp and some other languages, and it still works like it was before.

@UnrealQuester
Copy link
Collaborator

The patch was merged into the current vim master as patch 1691. Can anyone confirm that the bug is now fixed with the latest version of vim?

@jeaye Do you think we should add a FAQ entry or something for this?

@alientechnology
Copy link

@UnrealQuester I confirm. Just built vim 1691 from git, and our problem isn't there anymore.

@jeaye
Copy link
Owner

jeaye commented Apr 3, 2016

@UnrealQuester Yep, I think a FAQ entry would be good.

@jeaye jeaye closed this as completed Apr 3, 2016
jeaye added a commit that referenced this issue Apr 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants