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

Vim crashes after ycmd #593

Closed
oblitum opened this issue Oct 18, 2013 · 23 comments
Closed

Vim crashes after ycmd #593

oblitum opened this issue Oct 18, 2013 · 23 comments

Comments

@oblitum
Copy link
Contributor

oblitum commented Oct 18, 2013

I've switched to ycmd and I perceived (I think) some random crashes from time to time, it was sowewhat difficult to reduce the occasion where it would happen consistently, I have a consistent crash in the following situation,

typed boost::bima:

then tab, tab, tab:

in the fourth tab, vim crashes.

It's aways this situation, going through the popup options with tab, a random crash occurs.
Still not sure whether ycmd is the real cause.

@oblitum
Copy link
Contributor Author

oblitum commented Oct 18, 2013

Vim Version:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Sep  7 2013 16:21:31)
Correções incluídas: 1-22
Compilado por francisco@oblita.com
Versão enorme com interface GTK2.  Recursos incluídos (+) ou não (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
+balloon_eval    +float           +mouse_urxvt     -tag_any_white
+browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
+clientserver    -hangul_input    +netbeans_intg   +title
+clipboard       +iconv           +path_extra      +toolbar
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con_gui  +lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      +X11
+dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     +xim
+emacs_tags      +mouseshape      -sniff           +xsmp_interact
+eval            +mouse_dec       +startuptime     +xterm_clipboard
+ex_extra        -mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
    arquivo vimrc de sistema: "$VIM/vimrc"
    arquivo vimrc do usuário: "$HOME/.vimrc"
 2º arquivo vimrc do usuário: "~/.vim/vimrc"
     arquivo exrc do usuário: "$HOME/.exrc"
   arquivo gvimrc de sistema: "$VIM/gvimrc"
   arquivo gvimrc do usuário: "$HOME/.gvimrc"
2º arquivo gvimrc do usuário: "~/.vim/gvimrc"
  arquivo de menu do sistema: "$VIMRUNTIME/menu.vim"
            padrão para $VIM: "/usr/local/share/vim"
Compilação: 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/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/harfbuzz   -I/usr/local/include  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Vinculação: gcc   -L. -L/home/francisco/.rbenv/versions/2.0.0-p247/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 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0   -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl   -ldl  -L/usr/lib -llua5.1 -Wl,-E  -fstack-protector -L/usr/local/lib  -L/usr/lib/perl/5.14/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   -Wl,-R -Wl,/home/francisco/.rbenv/versions/2.0.0-p247/lib -L/home/francisco/.rbenv/versions/2.0.0-p247/lib -lruby-static -lpthread -lrt -ldl -lcrypt -lm  -L/home/francisco/.rbenv/versions/2.0.0-p247/lib

Ubuntu 13.04, Clang version 3.4 (trunk 190255).

@Valloric
Copy link
Member

I'm going to have to take a closer look at this, but at first glance, I'd put my money on a Vim bug. The ycmd server cannot crash your Vim because it runs inside a separate process; the ycm client code running inside Vim gets JSON from ycmd.

This is then transformed into data that is sent to Vim for display as a completion menu. The fact that the crash happens as you select an item in the completion menu very strongly suggests that this is a Vim bug. No YCM code runs when you tab through the menu, only Vim-internal code.

Try updating to the latest Vim version and see if you can still repro this.

@oblitum
Copy link
Contributor Author

oblitum commented Oct 18, 2013

@Valloric I know the separation between client and server, the question is that I wasn't suffering this before, and haven't updated Vim, so I thought it could be something to do with the client, more specifically filling the menu with data Vim doesn't like.

@oblitum
Copy link
Contributor Author

oblitum commented Oct 18, 2013

I'll try a Vim update to see whether it gets fixed.

@Valloric
Copy link
Member

It might be caused by filling the menu with data Vim doesn't like, but that would still be a bug in Vim because Vim shouldn't crash in such a situation.

That being said, YCM would then try to work around that Vim bug.

@oblitum
Copy link
Contributor Author

oblitum commented Oct 18, 2013

Just updated to tip of trunk, same problem:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 18 2013 00:12:00)
Correções incluídas: 1-52
Compilado por francisco@oblita.com
Versão enorme com interface GTK2.  Recursos incluídos (+) ou não (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
+balloon_eval    +float           +mouse_urxvt     -tag_any_white
+browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
+clientserver    -hangul_input    +netbeans_intg   +title
+clipboard       +iconv           +path_extra      +toolbar
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con_gui  -lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      +X11
+dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     +xim
+emacs_tags      +mouseshape      -sniff           +xsmp_interact
+eval            +mouse_dec       +startuptime     +xterm_clipboard
+ex_extra        -mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
    arquivo vimrc de sistema: "$VIM/vimrc"
    arquivo vimrc do usuário: "$HOME/.vimrc"
 2º arquivo vimrc do usuário: "~/.vim/vimrc"
     arquivo exrc do usuário: "$HOME/.exrc"
   arquivo gvimrc de sistema: "$VIM/gvimrc"
   arquivo gvimrc do usuário: "$HOME/.gvimrc"
2º arquivo gvimrc do usuário: "~/.vim/gvimrc"
  arquivo de menu do sistema: "$VIMRUNTIME/menu.vim"
            padrão para $VIM: "/usr/local/share/vim"
Compilação: 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/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/harfbuzz   -I/usr/local/include  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Vinculação: gcc   -L. -L/home/francisco/.rbenv/versions/2.0.0-p247/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 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0   -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl   -ldl   -Wl,-E  -fstack-protector -L/usr/local/lib  -L/usr/lib/perl/5.14/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   -Wl,-R -Wl,/home/francisco/.rbenv/versions/2.0.0-p247/lib -L/home/francisco/.rbenv/versions/2.0.0-p247/lib -lruby-static -lpthread -lrt -ldl -lcrypt -lm  -L/home/francisco/.rbenv/versions/2.0.0-p247/lib

@oblitum
Copy link
Contributor Author

oblitum commented Oct 18, 2013

I had switched back to master and rebuild, no problems, then switched back to ycmd and rebuild, the issue is triggered.

@oblitum
Copy link
Contributor Author

oblitum commented Oct 18, 2013

on purpose, I'd like to comment on a kind of feature request, anytime Vim crashes one gets a leaked server instance, I then must go to system monitor and terminate the correspoding instance to the crashed Vim instance. It would be nice to have some kind of seppuku from the server part when a Vim client dies.

@Valloric
Copy link
Member

It would be nice to have some kind of seppuku from the server part when a Vim client dies.

This is actually already on my internal TODO list. There'll be a sort of suicide timer that will kill the server when no request has been received for some (configurable) time.

@oblitum
Copy link
Contributor Author

oblitum commented Oct 18, 2013

I think I hit the target, the other stuff that shows up with the "tab tab tab tab" is the preview window and its contents, so to make a simple test I've executed :set completeopt-=preview and now, on "tab tab tab tab", it's not crashing anymore for that case.

@Valloric
Copy link
Member

BTW thanks for continuing to test out ycmd and reporting issues. You've been a big help!

@oblitum
Copy link
Contributor Author

oblitum commented Oct 18, 2013

np :-)

@Valloric
Copy link
Member

I can't repro this. Here's my test file:

#include <boost/bimap.hpp>


int main() {

  // input goes below here
}

Below the comment, I type boost::bima and then press tab as much as I want, no crash.

Here's my extra conf for testing:

import os

flags = [
'-std=c++11',
'-x',
'c++',
'-isystem',
'../Downloads/boost_1_54_0',
]


def DirectoryOfThisScript():
  return os.path.dirname( os.path.abspath( __file__ ) )


def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
  if not working_directory:
    return list( flags )
  new_flags = []
  make_next_absolute = False
  path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
  for flag in flags:
    new_flag = flag

    if make_next_absolute:
      make_next_absolute = False
      if not flag.startswith( '/' ):
        new_flag = os.path.join( working_directory, flag )

    for path_flag in path_flags:
      if flag == path_flag:
        make_next_absolute = True
        break

      if flag.startswith( path_flag ):
        path = flag[ len( path_flag ): ]
        new_flag = path_flag + os.path.join( working_directory, path )
        break

    if new_flag:
      new_flags.append( new_flag )
  return new_flags


def FlagsForFile( filename ):
  relative_to = DirectoryOfThisScript()
  final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )

  return {
    'flags': final_flags,
    'do_cache': True
  }

As you can see, I have ../Downloads/boost_1_54_0 in my include paths. It points to a fresh, untouched copy of boost 1.54. I'm running the latest ycmd and Vim 7.3.831.

I have noticed you have enable_boost_move... as the last item in your menu; I don't get that.

@oblitum
Copy link
Contributor Author

oblitum commented Oct 18, 2013

I'm using boost from svn repo (compiled with clang & libc++), the last commit is:

r86327 | viboes | 2013-10-16 03:15:51 -0300 (Qua, 16 Out 2013)

My Vim is:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 18 2013 00:12:00)

changeset:   5404:92c9748e0ccb
tag:         tip
user:        Bram Moolenaar <bram@vim.org>
date:        Sun Oct 06 17:46:56 2013 +0200
summary:     Added tag v7-4-052 for changeset b9c1c1f4cda9

I'm using Ubuntu 13.04.

My .ycm_extra_conf is this:

import os
import ycm_core
from clang_helpers import PrepareClangFlags

# These are the compilation flags that will be used in case there's no
# compilation database set (by default, one is not set).
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
flags = [
'-x',
'c++',
'-Wall',
'-Wextra',
'-fPIE',
'-D_REENTRANT',
'-std=c++1y',
'-stdlib=libc++',
'-ftemplate-depth=8192',
'-fconstexpr-depth=8192',
'-lcxxrt',
'-ldl',
'-isystem',
'/usr/include/c++/v1',
'-isystem',
'/usr/local/include',
'-isystem',
'/usr/include/x86_64-linux-gnu',
'-isystem',
'/usr/include',

'-I',
'/usr/local/src/yeppp/1.0.0/library/headers',

'-I',
'/opt/qt/5.1.2/linux/mkspecs/linux-clang',
'-I',
'/opt/qt/5.1.2/linux/include',
'-I',
'/opt/qt/5.1.2/linux/include/QtCLucene',
'-I',
'/opt/qt/5.1.2/linux/include/QtConcurrent',
'-I',
'/opt/qt/5.1.2/linux/include/QtCore',
'-I',
'/opt/qt/5.1.2/linux/include/QtDBus',
'-I',
'/opt/qt/5.1.2/linux/include/QtDeclarative',
'-I',
'/opt/qt/5.1.2/linux/include/QtDesigner',
'-I',
'/opt/qt/5.1.2/linux/include/QtDesignerComponents',
'-I',
'/opt/qt/5.1.2/linux/include/QtGui',
'-I',
'/opt/qt/5.1.2/linux/include/QtHelp',
'-I',
'/opt/qt/5.1.2/linux/include/QtMultimedia',
'-I',
'/opt/qt/5.1.2/linux/include/QtMultimediaQuick_p',
'-I',
'/opt/qt/5.1.2/linux/include/QtMultimediaWidgets',
'-I',
'/opt/qt/5.1.2/linux/include/QtNetwork',
'-I',
'/opt/qt/5.1.2/linux/include/QtOpenGL',
'-I',
'/opt/qt/5.1.2/linux/include/QtOpenGLExtensions',
'-I',
'/opt/qt/5.1.2/linux/include/QtPlatformSupport',
'-I',
'/opt/qt/5.1.2/linux/include/QtPrintSupport',
'-I',
'/opt/qt/5.1.2/linux/include/QtQml',
'-I',
'/opt/qt/5.1.2/linux/include/QtQuick',
'-I',
'/opt/qt/5.1.2/linux/include/QtQuickParticles',
'-I',
'/opt/qt/5.1.2/linux/include/QtQuickTest',
'-I',
'/opt/qt/5.1.2/linux/include/QtScript',
'-I',
'/opt/qt/5.1.2/linux/include/QtScriptTools',
'-I',
'/opt/qt/5.1.2/linux/include/QtSensors',
'-I',
'/opt/qt/5.1.2/linux/include/QtSerialPort',
'-I',
'/opt/qt/5.1.2/linux/include/QtSql',
'-I',
'/opt/qt/5.1.2/linux/include/QtSvg',
'-I',
'/opt/qt/5.1.2/linux/include/QtTest',
'-I',
'/opt/qt/5.1.2/linux/include/QtUiTools',
'-I',
'/opt/qt/5.1.2/linux/include/QtV8',
'-I',
'/opt/qt/5.1.2/linux/include/QtWebKit',
'-I',
'/opt/qt/5.1.2/linux/include/QtWebKitWidgets',
'-I',
'/opt/qt/5.1.2/linux/include/QtWidgets',
'-I',
'/opt/qt/5.1.2/linux/include/QtX11Extras',
'-I',
'/opt/qt/5.1.2/linux/include/QtXml',
'-I',
'/opt/qt/5.1.2/linux/include/QtXmlPatterns'
]

# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''

if compilation_database_folder:
  database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
  database = None


def DirectoryOfThisScript():
  return os.path.dirname( os.path.abspath( __file__ ) )


def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
  if not working_directory:
    return flags
  new_flags = []
  make_next_absolute = False
  path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
  for flag in flags:
    new_flag = flag

    if make_next_absolute:
      make_next_absolute = False
      if not flag.startswith( '/' ):
        new_flag = os.path.join( working_directory, flag )

    for path_flag in path_flags:
      if flag == path_flag:
        make_next_absolute = True
        break

      if flag.startswith( path_flag ):
        path = flag[ len( path_flag ): ]
        new_flag = path_flag + os.path.join( working_directory, path )
        break

    if new_flag:
      new_flags.append( new_flag )
  return new_flags


def FlagsForFile( filename ):
  if database:
    # Bear in mind that compilation_info.compiler_flags_ does NOT return a
    # python list, but a "list-like" StringVec object
    compilation_info = database.GetCompilationInfoForFile( filename )
    final_flags = PrepareClangFlags(
        MakeRelativePathsInFlagsAbsolute(
            compilation_info.compiler_flags_,
            compilation_info.compiler_working_dir_ ),
        filename )
  else:
    relative_to = DirectoryOfThisScript()
    final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )

  return {
    'flags': final_flags,
    'do_cache': True
  }

My .vimrc is this: https://gist.github.com/oblitum/5565974.

YCM installation was through:

./install.sh --clang-completer --system-libclang

My llvm/clang version is clang version 3.4 (trunk 190255) (compiled from sources).

My libc++ version is:

r191148 | hhinnant | 2013-09-21 18:26:37 -0300 (Sat, 21 Sep 2013)

If you get unable to reproduce this, I think I may have to figure it out myself, I only know this is related with the preview window, only with ycmd.

@Valloric
Copy link
Member

Can you repro the issue with the test case/extra conf I posted?

@oblitum
Copy link
Contributor Author

oblitum commented Oct 21, 2013

I have inspected this is a Vim bug, will report it upstream as soon as I can.

@oblitum oblitum closed this as completed Oct 21, 2013
@oblitum
Copy link
Contributor Author

oblitum commented Oct 21, 2013

for reference, this is the Vim thread discussing this issue:

https://groups.google.com/forum/#!topic/vim_dev/DBtKhz7gKL0

@Valloric
Copy link
Member

Thanks for reporting this upstream (and providing a patch)!

@Valloric
Copy link
Member

If anyone has this problem, you need to update to latest Syntastic.

Valloric added a commit that referenced this issue Dec 10, 2013
This gets rid of the annoying flashing (issue #669), but reverts the workaround
for a rare Vim crash bug (issue #593). We can't have both. Update to latest Vim
to not get the crash bug.

Fixes #669.
Valloric added a commit that referenced this issue Dec 10, 2013
Happens sometimes when users tab through the completion menu. Related to #593.
Valloric added a commit that referenced this issue Dec 27, 2013
This reverts commit 4d8fea4.

Since the commit we are reverting didn't resolve #669, we are reverting it to
fix #593 (again).
@irakli-lekishvili
Copy link

oblitum sorry but which color scheme do you use?

@oblitum
Copy link
Contributor Author

oblitum commented May 26, 2014

@lekishvili I use gruvbox, this is my .vimrc: https://gist.github.com/oblitum/5565974

@oblitum
Copy link
Contributor Author

oblitum commented May 27, 2014

@lekishvili from discussion in #1000 I just started using octol/vim-cpp-enhanced-highlight too =)

@irakli-lekishvili
Copy link

@oblitum thank you )

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants