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

Buffer does not exist: -1 on ToggleMarkbar #3

Closed
mwgkgk opened this issue Sep 13, 2018 · 9 comments
Closed

Buffer does not exist: -1 on ToggleMarkbar #3

mwgkgk opened this issue Sep 13, 2018 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@mwgkgk
Copy link

mwgkgk commented Sep 13, 2018

On ToggleMarkbar:

Error detected while processing function markbar#ui#ToggleMarkbar[1]..markbar#MarkbarState#toggleMarkbar[3]..markbar#MarkbarState#openMarkbar[5]..markbar#MarkbarState#getMarkbarBuffer[10]..markbar#ui#SetMarkbarBufferSettings:
line    2:
E605: Exception not caught: (markbar#ui#SetMarkbarBufferSettings) Buffer does not exist: -1

With this .vimrc:

set nocompatible

call plug#begin('~/.vim/bundle/')

Plug 'Yilin-Yang/vim-markbar'

call plug#end()

map ,m <Plug>ToggleMarkbar

Both on vim & nvim:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 29 2018 20:42:12)
Included patches: 1-333
Compiled by Arch Linux
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl               +extra_search      +mouse_netterm     +tag_old_static
+arabic            +farsi             +mouse_sgr         -tag_any_white
+autocmd           +file_in_path      -mouse_sysmouse    +tcl/dyn
+autochdir         +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
+balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
+browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          +toolbar
+cindent           +insert_expand     +path_extra        +user_commands
+clientserver      +job               +perl/dyn          +vartabs
+clipboard         +jumplist          +persistent_undo   +vertsplit
+cmdline_compl     +keymap            +postscript        +virtualedit
+cmdline_hist      +lambda            +printer           +visual
+cmdline_info      +langmap           +profile           +visualextra
+comments          +libcall           +python/dyn        +viminfo
+conceal           +linebreak         +python3/dyn       +vreplace
+cryptv            +lispindent        +quickfix          +wildignore
+cscope            +listcmds          +reltime           +wildmenu
+cursorbind        +localmap          +rightleft         +windows
+cursorshape       +lua/dyn           +ruby/dyn          +writebackup
+dialog_con_gui    +menu              +scrollbind        +X11
+diff              +mksession         +signs             -xfontset
+digraphs          +modify_fname      +smartindent       +xim
+dnd               +mouse             +startuptime       -xpm
-ebcdic            +mouseshape        +statusline        +xsmp_interact
+emacs_tags        +mouse_dec         -sun_workshop      +xterm_clipboard
+eval              +mouse_gpm         +syntax            -xterm_save
+ex_extra          -mouse_jsbterm     +tag_binary
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/uuid -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/libdrm -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -pthread  -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.28/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0  -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lelf -lnsl    -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.28/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/5.28/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm
NVIM v0.3.1
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Wconversion -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -Wno-array-bounds -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.3.1/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Compiled by builduser

Features: +acl +iconv +jemalloc +tui

💜

Yilin-Yang added a commit that referenced this issue Sep 13, 2018
Markbar buffer should be created and initialized automatically inside of
`MarkbarState#getMarkbarBuffer()` by the time it calls
`ui#SetMarkbarBufferSettings`; on the off-chance that `bufexists` is
somehow failing inside of `getMarkbarBuffer` but not
`SetMarkbarBufferSettings`, add explicit checks for an "uninitialized"
markbar buffer value.
@Yilin-Yang
Copy link
Owner

I can't reproduce this on my machine, unfortunately (using the provided vimrc, vim 8.1, neovim 0.3.1, on WSL Ubuntu 16.04).

The thing that most confuses me is that the exception you saw should be logically impossible: the second-topmost function in the call stack (MarkbarState#getMarkbarBuffer) explicitly checks whether the markbar buffer exists (-1 is the default value, which should be guaranteed to be a nonexistent buffer), and should initialize it if it doesn't. I have a few ideas of what might cause this, but they're all long shots (e.g. something weird going on with string comparisons, some bizarre regression in the most recent builds of vim 8.1, etc.)

Would you mind trying a few things for me, and reporting whether they fixed the issue?

  1. Try mapping ,m to <Plug>OpenMarkbar instead of <Plug>ToggleMarkbar, and then try to open the markbar.
  2. Try cloning from the new issue_3 branch, and see if the issue still occurs there.
  3. Try cloning from the mvc branch, and see if the issue still occurs there.

Sorry to see that the plugin isn't behaving; here's hoping that we can get this fixed sharpish!

@Yilin-Yang Yilin-Yang self-assigned this Sep 13, 2018
@Yilin-Yang Yilin-Yang added question Further information is requested bug Something isn't working and removed question Further information is requested labels Sep 13, 2018
@mwgkgk
Copy link
Author

mwgkgk commented Sep 14, 2018

OpenMarkbar gives same results. issue_3 gives same results. mvc breaks with this:

Error detected while processing function markbar#MarkbarController#openMarkbar[6]..markbar#MarkbarView#openMarkbar[2]..markbar#MarkbarView#getMarkbarBuffer[9]..markbar#MarkbarView#_setMarkbarBufferSettings:
line    3:
E605: Exception not caught: (MarkbarView#_setMarkbarBufferSettings) Buffer does not exist: -1
Error detected while processing function markbar#MarkbarController#openMarkbar[6]..markbar#MarkbarView#openMarkbar[2]..markbar#MarkbarView#getMarkbarBuffer:
line    9:
E171: Missing :endif

That's not a lot to go on : /

@Yilin-Yang
Copy link
Owner

Drat. That's a bummer. :(

I'll try to work on this again as soon as I'm able, but my university's career fair is coming up, so I won't realistically be able to make any progress at all until (probably) the end of this coming week.

Thanks for your help, and for your patience; I'll be in touch soon!

Yilin-Yang added a commit that referenced this issue Oct 13, 2018
Tentative fix for #3. Running hypothesis is that `badd` is successfully
creating a new buffer for the markbar, but that the following call to
`bufnr` can't find it in the buffer list (thereby returning '-1').

Try to circumvent this by creating the markbar buffer using `bufnr`, and
using its return value. Also, default-initialize
MarkbarView::_markbar_buffer to -2 instead of -1, to differentiate
between `badd` failure and `bufnr` failure.
@Yilin-Yang
Copy link
Owner

Apologies for the wait; recruiting season and classes took more out of me than I'd anticipated.

I think that I've nailed down what the problem might be; could you clone from the mvc branch and see if the issue's been fixed? (Please post the error message if it doesn't!)

@mwgkgk
Copy link
Author

mwgkgk commented Oct 13, 2018

Opens now! All the calls function as expected, except ?:

Error detected while processing function markbar#MarkbarView#toggleShowHelp[1]..markbar#MarkbarModel#AssertIsMarkbarModel:
line    2:
E731: using Dictionary as a String
E15: Invalid expression: '(markbar#MarkbarModel) Object is not of type MarkbarModel: ' . a:object

Also, conflicts with Ale, when opening markbar on the first-and-only file opened in vim, and on every keypress after that:

Error detected while processing function ale#events#LintOnEnter[5]..ale#Queue[49]..ale#Lint[34]..ale#engine#RunLinters[28]..ale#engine#SetResults[6]..ale#sign#SetSigns[8]..ale#sign#FindCurrentSigns[1]..ale#sign#ReadSigns:
line    1:
E121: Undefined variable: l:to_return

Without ale, when trying to open markbar on the first-and-only file opened in vim:

line    8:
E605: Exception not caught: (markbar#ConditionalStack) Called top() when empty!

On subsequent calls in the same file

Error detected while processing function markbar#MarkbarController#toggleMarkbar[2]..markbar#MarkbarView#closeMarkbar:
line    5:
E444: Cannot close last window

Without ale the error does not persist on every keypress and all works as expected once we open more than one file.

Opening markbar on an empty file, only on first call, only in vim:

Error detected while processing function <SNR>77_BEAddBuffer[2]..<SNR>77_BEGetBufferInfo:
line    1:
E121: Undefined variable: l:to_return
  1 %a   "[No Name]"                    line 1
  2u     "[ Markbar ]"                  line 1

Behavior differs in vim and nvim in that nvim has '1 - '7 marks set to what I assume are some entries from the jumplist (not following :jumps exactly but same files, regardless of having marks in the files), I did not find neovim documentation on that, but this behavior fixes the open-markbar-on-empty-file bug (which is exactly empty file when opening vim without arguments. a file with no marks (or a new empty buffer) works fine as long as it's not the only file opened so that it does not trigger the bugs above). Rest behaviors reproducible in both.

Seems like a handful, please don't feel like you should compromise the planned activities

@Yilin-Yang
Copy link
Owner

No worries, dude! We're on break right now, and it's a pleasure and a relief to spend some time working on a personal project instead of stressing about coursework. :) And thanks a bunch for the detailed error messages, they're very helpful!

I think I've fixed the ? mapping as well as the Called top() when empty!/Cannot close last window errors, though I'm not sure about ALE. Could you pull from mvc again and see if the issues have been fixed?

@mwgkgk
Copy link
Author

mwgkgk commented Oct 14, 2018

Confirmed: ? works, first file opened errors are gone, with the exception of file(s) passed as an argument (or empty file) when first opening the editor, regardless of having marks:

Error detected while processing function <SNR>77_BEAddBuffer[2]..<SNR>77_BEGetBufferInfo:
line    1:
E121: Undefined variable: l:to_return

Only happens in vim, fixes itself after first call. I thought it doesn't happen in nvim because of '1 - '7 marks defined by default, but it does occur in vim even if the marks are present in the file (that was passed as arg. switching files fixes it)

Error detected while processing function <SNR>77_BEAddBuffer[2]..<SNR>77_BEGetBufferInfo:
line    1:
E121: Undefined variable: l:to_return
  1 %a   ".Xresources"                  line 83
  2u     "( Markbar )"                  line 1

Previous Ale errors don't occur. Now, once Markbar has been opened and closed in a session, it errors out on opening files (e.g. with :e):

Error detected while processing function ale#events#LintOnEnter[5]..ale#Queue[49]..ale#Lint[34]..ale#engine#RunLinters[28]..ale#engine#SetResults[6]..ale#sign#SetSigns[8]..ale#sign#FindCurrentSigns[1]..ale#sign#ReadSigns:
line    1:
E121: Undefined variable: l:to_return
Error detected while processing function ale#events#LintOnEnter[5]..ale#Queue[49]..ale#Lint[34]..ale#engine#RunLinters[28]..ale#engine#SetResults[6]..ale#sign#SetSigns:
line    8:
E714: List required

If Markbar is still open (with ale on) when opening a file, two new errors show up in addition to the above:

Error detected while processing function markbar#ui#RefreshMarkbar[5]..markbar#MarkbarController#openMarkbar[5]..markbar#MarkbarModel#updateCurrentAndGlobal[4]..markbar#helpers#GetLocalMarks:
line    3:
E121: Undefined variable: l:output
Press ENTER or type command to continue
Error detected while processing function markbar#ui#RefreshMarkbar:
line    5:
E171: Missing :endif

These Ale errors don't occur in nvim. Thus the remaining bugs are all contained to vim.

@Yilin-Yang
Copy link
Owner

Added a fix that might address the E121: Undefined variable: l:to:return issue, which I've pushed to mvc. (I was able to produce a different error by opening an empty file in vim, and then trying to open the markbar; it may not be the same issue, but the two might be connected.) Could you take a look and see if that problem's been fixed? If it has, and if I haven't introduced any regressions, then I would feel comfortable marking this issue as resolved.

Which isn't to say that I won't work on the ALE errors! I'm just not able to replicate them on my machine, and they're somewhat beyond this issue's original scope, so it would be helpful if you could create another issue with an accompanying minimal .vimrc.

Again, thanks so much for your help! You've helped me unearth a few very obscure bugs and errors that I wouldn't have noticed otherwise!

@mwgkgk
Copy link
Author

mwgkgk commented Oct 15, 2018

You're right! I've messed up. The BEAddBuffer bug was from interacting with bufexplorer.

At this point it seems getting my hands dirty and actually digging into this is a reasonable course of action, we've done enough ghost debugging as it is. Not being able to reproduce is a pain in the buttocks. Thank you for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants