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

cmd/govim: panic handling GOVIMQuickfixDiagnostics #680

Closed
myitcv opened this issue Jan 16, 2020 · 0 comments · Fixed by #840
Closed

cmd/govim: panic handling GOVIMQuickfixDiagnostics #680

myitcv opened this issue Jan 16, 2020 · 0 comments · Fixed by #840
Labels
bug Something isn't working
Milestone

Comments

@myitcv
Copy link
Member

myitcv commented Jan 16, 2020

What version of Vim/Gvim are you using?

Vim/Gvim version
$ vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jan  7 2020 12:54:48)
Included patches: 1-96
Compiled by myitcv@myitcv
Huge version with GTK2 GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_old_static
+arabic            +file_in_path      +mouse_urxvt       -tag_any_white
+autocmd           +find_in_path      +mouse_xterm       -tcl
+autochdir         +float             +multi_byte        +termguicolors
-autoservername    +folding           +multi_lang        +terminal
+balloon_eval      -footer            -mzscheme          +terminfo
+balloon_eval_term +fork()            -netbeans_intg     +termresponse
+browse            +gettext           +num64             +textobjects
++builtin_terms    -hangul_input      +packages          +textprop
+byte_offset       +iconv             +path_extra        +timers
+channel           +insert_expand     -perl              +title
+cindent           +job               +persistent_undo   +toolbar
+clientserver      +jumplist          +popupwin          +user_commands
+clipboard         +keymap            +postscript        +vartabs
+cmdline_compl     +lambda            +printer           +vertsplit
+cmdline_hist      +langmap           +profile           +virtualedit
+cmdline_info      +libcall           +python/dyn        +visual
+comments          +linebreak         +python3/dyn       +visualextra
+conceal           +lispindent        +quickfix          +viminfo
+cryptv            +listcmds          +reltime           +vreplace
+cscope            +localmap          +rightleft         +wildignore
+cursorbind        +lua               -ruby              +wildmenu
+cursorshape       +menu              +scrollbind        +windows
+dialog_con_gui    +mksession         +signs             +writebackup
+diff              +modify_fname      +smartindent       +X11
+digraphs          +mouse             -sound             -xfontset
+dnd               +mouseshape        +spell             +xim
-ebcdic            +mouse_dec         +startuptime       +xpm
+emacs_tags        -mouse_gpm         +statusline        +xsmp_interact
+eval              -mouse_jsbterm     -sun_workshop      +xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +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"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/home/myitcv/usr/vim/share/vim"
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/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16   -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -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 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl    -ldl  -L/usr/lib/x86_64-linux-gnu -lluajit-5.1         

What version of Go are you using (go version)?

$ go version
go version devel +693748e9fa Mon Jan 6 11:46:56 2020 +0000 linux/amd64

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOENV="/home/myitcv/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/myitcv/gos"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build953932311=/tmp/go-build -gno-record-gcc-switches"

What version/commit of govim are you using?

29461d3

What is the output of :messages in Vim?

See below

Do the Vim channel or govim log files show anything interesting?

got error whilst handling command:GOVIMQuickfixDiagnostics: caught panic: runtime error: index out of range [3] with length 1
goroutine 2582 [running]:
github.com/govim/govim.(*govimImpl).run.func8.1.1(0xc00020beb0, 0xc000130000)
	/home/myitcv/.vim/plugged/govim/govim.go:527 +0x181
panic(0x644fa0, 0xc00023a1a0)
	/home/myitcv/gos/src/runtime/panic.go:967 +0x15d
github.com/govim/govim/internal/plugin.Driver.do.func1(0xc00020bc70)
	/home/myitcv/.vim/plugged/govim/internal/plugin/plugin.go:53 +0xd4
panic(0x644fa0, 0xc00023a1a0)
	/home/myitcv/gos/src/runtime/panic.go:967 +0x15d
main.(*vimstate).updateQuickfix(0xc000001980, 0xc000222000, 0x1, 0x1, 0xc000135a01, 0x54a516, 0xc00020fda0)
	/home/myitcv/.vim/plugged/govim/cmd/govim/quickfix.go:60 +0xbd8
main.(*vimstate).quickfixDiagnostics(0xc000001980, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/myitcv/.vim/plugged/govim/cmd/govim/quickfix.go:20 +0x45
github.com/govim/govim/internal/plugin.Driver.doCommandFunction.func1.1(0x5a88b4, 0x5d8388)
	/home/myitcv/.vim/plugged/govim/internal/plugin/plugin.go:218 +0xc6
github.com/govim/govim/internal/plugin.Driver.do(0x6b36e0, 0xc000130000, 0x66327f, 0x5, 0xc0005c7c80, 0x0, 0x0)
	/home/myitcv/.vim/plugged/govim/internal/plugin/plugin.go:57 +0x5b
github.com/govim/govim/internal/plugin.Driver.doCommandFunction.func1(0x6b36e0, 0xc000130000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/myitcv/.vim/plugged/govim/internal/plugin/plugin.go:217 +0x111
github.com/govim/govim.(*govimImpl).run.func6(0x0, 0xc0005c7e30, 0x5594ef, 0xc0005c7eb0)
	/home/myitcv/.vim/plugged/govim/govim.go:507 +0xea
github.com/govim/govim.(*govimImpl).run.func8.1(0xc00020beb0, 0xc000130000, 0xc000192240, 0xc00020bea0)
	/home/myitcv/.vim/plugged/govim/govim.go:535 +0x62
github.com/govim/govim.(*govimImpl).run.func8(0x0, 0x0)
	/home/myitcv/.vim/plugged/govim/govim.go:536 +0xd1
github.com/govim/govim.(*govimImpl).runEventQueue.func1(0xc0000167a8, 0xc000100db0)
	/home/myitcv/.vim/plugged/govim/govim.go:606 +0x26
github.com/govim/govim.(*govimImpl).goHandleShutdown.func1(0x0, 0x0)
	/home/myitcv/.vim/plugged/govim/govim.go:281 +0x54
gopkg.in/tomb%!e(MISSING)v2.(*Tomb).run(0xc00011e0a0, 0xc00020fe20)
	/home/myitcv/gostuff/pkg/mod/gopkg.in/tomb.v2@v2.0.0-20161208151619-d5d1b5820637/tomb.go:163 +0x38
created by gopkg.in/tomb%!e(MISSING)v2.(*Tomb).Go
	/home/myitcv/gostuff/pkg/mod/gopkg.in/tomb.v2@v2.0.0-20161208151619-d5d1b5820637/tomb.go:159 +0xba

How did you install govim?

n/a

What did you do?

  • Used :GOVIMReferences to find references to an identifier
  • Selected the third reference using the cursor in the quickfix window
  • Ran :GOVIMQuickfixDiagnostics to show diagnostic errors (there was only one diagnostic error at this point)

What did you expect to see?

The diagnostic shown in the quickfix window.

What did you see instead?

Panic.

We are not correctly storing the selected index for the different modes of the quickfix window. Hence we grab the currently selected index when in references mode (3, 1-indexed) and try to use that when then showing errors (of which there is only one)

We should push/pop this state when flipping modes, but also add checks that we don't ever select past the end of the diagnostics/references.

And we should add a test for this flipping between modes.

@myitcv myitcv added the bug Something isn't working label Jan 16, 2020
@myitcv myitcv added this to the Next milestone Jan 16, 2020
myitcv added a commit that referenced this issue Apr 2, 2020
myitcv added a commit that referenced this issue Apr 2, 2020
myitcv added a commit that referenced this issue Apr 2, 2020
myitcv added a commit that referenced this issue Apr 7, 2020
myitcv added a commit that referenced this issue Apr 7, 2020
…cs (#840)

See the description in the linked issue.

Fixes #680
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

Successfully merging a pull request may close this issue.

1 participant