Please complete these steps and check these boxes (by putting an x inside
the brackets) _before_ filing your issue:
vim --version.:YcmDebugInfo.:YcmToggleLogs command.vim -Nu /path/to/YCM/vimrc_ycm_minimal, including what Iinstall.py (or cmake/make/ninja) including its invocationThank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.
Provide a clear description of the problem, including the following key
questions:
YouCompleteMe worked fine for me till I pulled new commits today. Now, the semantic completion, and YcmCompleter subcommands don't work on cpp files.
++ To reproduce the issue, I did a fresh git-clone, and then a fresh install of YouCompleteMe plugin from github.
++ Then I downloaded the llvm 10.0.0 from llvm.org
++ I found that for cpp files, the semantic autocomplete doesn't work.
Include steps to reproduce here.
Attached is the source code.
example3.zip
The source code tree looks like this
example3
โโโ CMakeLists.txt
โโโ header
โย ย โโโ cheader.h
โโโ src
โโโ circle.cpp
โโโ main.cpp
For generating compile_commands.json, I followed these steps:
mkdir build
cd build
cmake -G "Unix Makefiles" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../example3
cd ../example3vim -Nu ~/.minimal_vimrc.vim src/main.cpp7jo and type cc.Area()Include description of a minimal test case, including any actual code required
to reproduce the issue.
See above
If you made changes to
vimrc_ycm_minimal, pase them here:
set nocompatible
set hls
syntax on
filetype plugin indent on
set completeopt = "menu"
" Youcompleteme
let g:ycm_clangd_binary_path = '/home/apathak/local/llvm_root_dir/bin/clangd'
let g:ycm_clangd_args = [
\ '--compile-commands-dir=../build',
\ '--completion-style=bundled',
\ '--fallback-style=Google',
\ '--header-insertion=iwyu',
\ '--suggest-missing-includes'
\ ]
let g:ycm_auto_trigger = 1
let g:ycm_goto_buffer_command = 'split-or-existing-window'
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_show_diagnostics_ui = 1
let g:ycm_log_level = 'debug'
packadd YouCompleteMe
Include description of the expected behaviour.
I expected the semantic autocomplete to trigger when I pressed Ctrl+Space, and when the dot in cc.Area was typed.
Include description of the observed behaviour, including actual output,
screenshots, etc.
The semantic autocomplete did not work.
vim --versionHuge 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 +visual
+comments +linebreak +python3 +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/apathak/local/vim2/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/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/gdk-pixbuf-2.0 -I/usr/include/libpng16 -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 -I/usr/include/libpng16 -I/usr/include/freetype2 -I/usr/include/libpng16 -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -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 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -lselinux -lcanberra -ldl -L/usr/lib -llua5.1 -Wl,-E -fstack-protector-strong -L/usr/local/lib -L/usr/lib/x86_64-linux-gnu/perl/5.26/CORE -lperl -ldl -lm -lpthread -lcrypt -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm -lruby-2.5 -lpthread -lgmp -ldl -lcrypt -lm
YcmDebugInfoPrinting YouCompleteMe debug information...
-- Completion API: 1
-- Client logfile: /tmp/ycm_3mcnk__o.log
-- Server Python interpreter: /usr/bin/python3
-- Server Python version: 3.6.9
-- Server has Clang support compiled in: False
-- Clang version: None
-- No extra configuration file found
-- C-family completer debug information:
-- Clangd not running
-- Clangd executable: ['/home/apathak/local/llvm_root_dir/bin/clangd', '--compile-commands-dir=../build', '--completion-style=bundle
d', '--fallback-style=Google', '--header-insertion=iwyu', '--suggest-missing-includes', '-header-insertion-decorators=0', '-limit-resu
lts=500', '-log=verbose']
-- Clangd logfiles:
-- /tmp/clangd_stderr6_ghagdh.log
-- Clangd Server State: Dead
-- Clangd Project Directory: /home/apathak/codes/scratch/example2
-- Clangd Settings: {}
-- Clangd Compilation Command: False
-- Server running at: http://127.0.0.1:46205
-- Server process ID: 15857
-- Server logfiles:
-- /tmp/ycmd_46205_stdout_cbv6t0uu.log
-- /tmp/ycmd_46205_stderr_4100y0px.log
YcmDiagsNo warnings or errors detected.
git rev-parse HEAD in YouCompleteMe installation directory
Reproduce the issue with
vim -Nu /path/to/YCM/vimrc_ycm_minimal, which
enabled debug logging and other useful diagnostics. Include a link to a
gist containing all of the log files listed by:YcmToggleLogs.
ycmd_46205_stdout_cbv6t0uu.log
ycmd_46205_stderr_4100y0px.log
ycm_3mcnk__o.log
clangd_stderr6_ghagdh.log
Include system information here.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
Include link to a gist containing the invocation and entire output of
install.pyif reporting an installation issue.
Looks like clangd is crashing. @kadircet could you check the clangd log in the report?
E[02:22:18.834] Error while reading shard /home/apathak/codes/scratch/example2/src/circle.cpp: #0 0x00000000004b4054 PrintStackTraceSignalHandler(void*) (/home/apathak/local/llvm_root_dir/bin/clangd+0x4b4054)
#1 0x00000000004b201c llvm::sys::RunSignalHandlers() (/home/apathak/local/llvm_root_dir/bin/clangd+0x4b201c)
#2 0x00000000004b4415 SignalHandler(int) (/home/apathak/local/llvm_root_dir/bin/clangd+0x4b4415)
#3 0x00007f1b968e5890 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
#4 0x00000000004242ea llvm::detail::ErrorAdapter::format(llvm::raw_ostream&, llvm::StringRef) (/home/apathak/local/llvm_root_dir/bin/clangd+0x4242ea)
#5 0x00000000004a3600 llvm::formatv_object_base::format(llvm::raw_ostream&) const (/home/apathak/local/llvm_root_dir/bin/clangd+0x4a3600)
#6 0x00000000004a3541 llvm::raw_ostream::operator<<(llvm::formatv_object_base const&) (/home/apathak/local/llvm_root_dir/bin/clangd+0x4a3541)
#7 0x00000000004a3600 llvm::formatv_object_base::format(llvm::raw_ostream&) const (/home/apathak/local/llvm_root_dir/bin/clangd+0x4a3600)
#8 0x00000000004a3541 llvm::raw_ostream::operator<<(llvm::formatv_object_base const&) (/home/apathak/local/llvm_root_dir/bin/clangd+0x4a3541)
#9 0x00000000009756d3 clang::clangd::StreamLogger::log(clang::clangd::Logger::Level, llvm::formatv_object_base const&) (/home/apathak/local/llvm_root_dir/bin/clangd+0x9756d3)
#10 0x00000000008ec9cc void clang::clangd::detail::log<llvm::StringRef&, llvm::Error>(clang::clangd::Logger::Level, char const*, llvm::StringRef&, llvm::Error&&) (/home/apathak/local/llvm_root_dir/bin/clangd+0x8ec9cc)
#11 0x00000000009f339c clang::clangd::(anonymous namespace)::DiskBackedIndexStorage::loadShard(llvm::StringRef) const (/home/apathak/local/llvm_root_dir/bin/clangd+0x9f339c)
#12 0x00000000009f1270 clang::clangd::loadIndexShards(llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, llvm::unique_function<clang::clangd::BackgroundIndexStorage* (llvm::StringRef)>&, clang::clangd::GlobalCompilationDatabase const&) (/home/apathak/local/llvm_root_dir/bin/clangd+0x9f1270)
#13 0x00000000009eb60d clang::clangd::BackgroundIndex::loadProject(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >) (/home/apathak/local/llvm_root_dir/bin/clangd+0x9eb60d)
#14 0x00000000009ecaf0 std::_Function_handler<void (), clang::clangd::BackgroundIndex::changedFilesTask(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&)::$_2>::_M_invoke(std::_Any_data const&) (/home/apathak/local/llvm_root_dir/bin/clangd+0x9ecaf0)
#15 0x00000000009f3a8d clang::clangd::BackgroundQueue::work(std::function<void ()>) (/home/apathak/local/llvm_root_dir/bin/clangd+0x9f3a8d)
#16 0x00000000009ec8f0 void llvm::unique_function<void ()>::CallImpl<clang::clangd::BackgroundIndex::BackgroundIndex(clang::clangd::Context, clang::clangd::FileSystemProvider const&, clang::clangd::GlobalCompilationDatabase const&, llvm::unique_function<clang::clangd::BackgroundIndexStorage* (llvm::StringRef)>, unsigned long)::$_1>(void*) (/home/apathak/local/llvm_root_dir/bin/clangd+0x9ec8f0)
#17 0x00000000009cc54b std::thread::_State_impl<std::thread::_Invoker<std::tuple<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_4, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, llvm::unique_function<void ()>, llvm::detail::scope_exit<clang::clangd::AsyncTaskRunner::runAsync(llvm::Twine const&, llvm::unique_function<void ()>)::$_0> > > >::_M_run() (/home/apathak/local/llvm_root_dir/bin/clangd+0x9cc54b)
#18 0x00007f1b95c336ef (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0xbd6ef)
#19 0x00007f1b968da6db start_thread /build/glibc-OTsEL5/glibc-2.27/nptl/pthread_create.c:463:0
#20 0x00007f1b9568e88f clone /build/glibc-OTsEL5/glibc-2.27/m
Clangd encountered an error and crashed. I'm suspecting either a bad compilation database or a mismatching index. Regenerate the compile_commands.json and remove the .clangd directory which contains the index. Then try again.
I deleted the .clangd folder, and YCM works now!
Thanks for the super prompt response.
Great. We can close this now.
yikes, the crash happens while printing the error. I can't reproduce on my side though, by indexing the attached project with first clangd 9 and then spinning up clangd 10. So it's likely that shard got corrupted somehow :/
Most helpful comment
I deleted the .clangd folder, and YCM works now!
Thanks for the super prompt response.