ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.44k stars 2.81k forks source link

[Windows] YCM launched python instance but sometimes does not close it when vim exits #3740

Closed unavaliabl3 closed 3 years ago

unavaliabl3 commented 4 years ago

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your issue:

Thank you for adhering to this process! It ensures your issue is resolved quickly and that neither your nor our time is needlessly wasted.

Issue Details

launch vim; edit code; exit vim

contents of ycm_vimrc_minimal

set encoding=utf-8                            "YCM requires UTF-8 encoding
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'VundleVim/Vundle.vim'          "Plugin Manager
Plugin 'ycm-core/YouCompleteMe'

call vundle#end()
filetype plugin indent on

YCM should terminate python process it launched when vim exits

YCM will launch one or two python instance for ycmd when running vim, but YCM sometimes doesn't terminate the python process automatically after vim exits. The picture below is showing the python process YCM has launched but didn't terminate on a Windows machine image I'm using CLI vim with a minimal .vimrc which only enables YCM and plugin manager in the above example. The same issue also exists when using Gvim

Diagnostic data

Output of vim --version

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Aug  7 2020 22:03:00)
MS-Windows 64-bit console version
Included patches: 1-1391
Compiled by appveyor@APPVYR-WIN
Huge version without GUI.  Features included (+) or not (-):
+acl                +ex_extra           +multi_lang         +tcl/dyn
+arabic             +extra_search       +mzscheme/dyn       +termguicolors
+autocmd            -farsi              -netbeans_intg      +terminal
+autochdir          +file_in_path       +num64              -termresponse
+autoservername     +find_in_path       +packages           +textobjects
-balloon_eval       +float              +path_extra         +textprop
+balloon_eval_term  +folding            +perl/dyn           -tgetent
-browse             -footer             +persistent_undo    +timers
++builtin_terms     +gettext/dyn        +popupwin           +title
+byte_offset        -hangul_input       -postscript         -toolbar
+channel            +iconv/dyn          +printer            +user_commands
+cindent            +insert_expand      +profile            +vartabs
+clientserver       +ipv6               +python/dyn         +vertsplit
+clipboard          +job                +python3/dyn        +virtualedit
+cmdline_compl      +jumplist           +quickfix           +visual
+cmdline_hist       +keymap             +reltime            +visualextra
+cmdline_info       +lambda             +rightleft          +viminfo
+comments           +langmap            +ruby/dyn           +vreplace
+conceal            +libcall            +scrollbind         +vtp
+cryptv             +linebreak          +signs              +wildignore
+cscope             +lispindent         +smartindent        +wildmenu
+cursorbind         +listcmds           +sound              +windows
+cursorshape        +localmap           +spell              +writebackup
+dialog_con         +lua/dyn            +startuptime        -xfontset
+diff               +menu               +statusline         -xim
+digraphs           +mksession          -sun_workshop       -xpm_w32
-dnd                +modify_fname       +syntax             -xterm_save
-ebcdic             +mouse              +tag_binary
+emacs_tags         -mouseshape         -tag_old_static
+eval               +multi_byte_ime/dyn -tag_any_white
   system vimrc file: "$VIM\vimrc"
     user vimrc file: "$HOME\_vimrc"
 2nd user vimrc file: "$HOME\vimfiles\vimrc"
 3rd user vimrc file: "$VIM\_vimrc"
      user exrc file: "$HOME\_exrc"
  2nd user exrc file: "$VIM\_exrc"
       defaults file: "$VIMRUNTIME\defaults.vim"
Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_TERMINAL -DFEAT_SOUND  -DFEAT_JOB_CHANNEL -DFEAT_IPV6      -DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /source-charset:utf-8 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG  /Zl /MT /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl86t.dll\" -DDYNAMIC_TCL_VER=\"8.6\" -DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua53.dll\" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python38.dll\" -DFEAT_MZSCHEME -I "C:\Program Files\Racket\include" -DMZ_PRECISE_GC -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"libracket3m_a36fs8.dll\" -DDYNAMIC_MZGC_DLL=\"libracket3m_a36fs8.dll\" -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl528.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_DLL=\"x64-msvcrt-ruby240.dll\" -DRUBY_VERSION=24 -DFEAT_HUGE /Fd.\ObjCULYHTRZAMD64/ /Zi
Linking: link  /nologo /opt:ref /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib netapi32.lib uuid.lib /machine:AMD64   libcmt.lib  user32.lib  /nodefaultlib:lua53.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python38.lib   "C:\Tcl\lib\tclstub86.lib" winmm.lib WSock32.lib Ws2_32.lib /PDB:vim.pdb -debug

Output of YcmDebugInfo

-- Completion API: 1
-- Client logfile: C:\Users\Ubuntu\AppData\Local\Temp\ycm_9vy20iim.log
-- Server Python interpreter: C:\Users\Ubuntu\AppData\Local\Programs\Python\Python38\python.exe
-- Server Python version: 3.8.5
-- Server has Clang support compiled in: False
-- Clang version: None
-- No extra configuration file found
-- Python completer debug information:
--   Python interpreter: C:\Users\Ubuntu\AppData\Local\Programs\Python\Python38\python.exe
--   Python root: C:\Users\Ubuntu
--   Python path: ['C:\\Users\\Ubuntu\\AppData\\Local\\Programs\\Python\\Python38\\python38.zip', 'C:\\Users\\Ubuntu\\AppData\\Local\\Programs\\Python\\Python38\\DLLs', 'C:\\Users\\Ubuntu\\AppData\\Local\\Programs\\Python\\Python38\\lib', 'C:\\Users\\Ubuntu\\AppData\\Local\\Programs\\Python\\Python38', 'C:\\Users\\Ubuntu\\AppData\\Roaming\\Python\\Python38\\site-packages', 'C:\\Users\\Ubuntu\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages']
--   Python version: 3.8.5
--   Jedi version: 0.17.0
--   Parso version: 0.7.0
-- Server running at: http://127.0.0.1:3806
-- Server process ID: 13204
-- Server logfiles:
--   C:\Users\Ubuntu\AppData\Local\Temp\ycmd_3806_stdout_b1ci26x0.log
--   C:\Users\Ubuntu\AppData\Local\Temp\ycmd_3806_stderr_tps4i88f.log

Output of YcmDiags

No warnings or errors detected.

Output of git rev-parse HEAD in YouCompleteMe installation directory

bcfd153813ac1f99947b706991eba2861f54a8a2

OS version, distribution, etc.

Windows_NT amd64 10.0.19041.388

puremourning commented 4 years ago

Thanks for the report. This is usually due to other plugins or auto commands interfering with the VimLeave auto command. Can you confirm the command you used to test with the minimal vimrc (just to rule out any interference).

puremourning commented 4 years ago

IF not, could you please provide the ycmd log file with;

let g:ycm_keep_logfiles = 1
let g:ycm_log_level = 'debug'
unavaliabl3 commented 4 years ago

command:

vim -Nu \tmp\.vimrc
set encoding=utf-8                            "YCM requires UTF-8 encoding
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'VundleVim/Vundle.vim'          "Plugin Manager
Plugin 'ycm-core/YouCompleteMe'

call vundle#end()
filetype plugin indent on

let g:ycm_keep_logfiles = 1                                                                      
let g:ycm_log_level = 'debug'

Logs

ycm.log

2020-08-17 00:04:05,438 - DEBUG - GET b'http://127.0.0.1:7685/ready' (None)
{'content-type': 'application/json', 'x-ycm-hmac': b'LdVbjKmdYo9IUnxVRV3uvNyEvgfJmuks+3TPzJUO++8='}
2020-08-17 00:04:05,534 - ERROR - HTTPConnectionPool(host='127.0.0.1', port=7685): Max retries exceeded with url: /ready (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x000001A5FBE5BFA0>, 'Connection to 127.0.0.1 timed out. (connect timeout=0.01)'))
2020-08-17 00:04:05,646 - DEBUG - GET b'http://127.0.0.1:7685/ready' (None)
{'content-type': 'application/json', 'x-ycm-hmac': b'LdVbjKmdYo9IUnxVRV3uvNyEvgfJmuks+3TPzJUO++8='}
2020-08-17 00:04:05,678 - ERROR - HTTPConnectionPool(host='127.0.0.1', port=7685): Max retries exceeded with url: /ready (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x000001A5FBE7A880>, 'Connection to 127.0.0.1 timed out. (connect timeout=0.01)'))
2020-08-17 00:04:05,778 - DEBUG - GET b'http://127.0.0.1:7685/ready' (None)
{'content-type': 'application/json', 'x-ycm-hmac': b'LdVbjKmdYo9IUnxVRV3uvNyEvgfJmuks+3TPzJUO++8='}
2020-08-17 00:04:05,806 - DEBUG - RX: <Response [200]>
true
2020-08-17 00:04:11,093 - DEBUG - POST b'http://127.0.0.1:7685/debug_info'
{'content-type': 'application/json', 'x-ycm-hmac': b'On2zB3jHYTaHC0e1Y7VSSJSXbH5ujOA8nVKGhs/Tci0='}
b'{"filepath": "C:\\\\Users\\\\Ubuntu\\\\1", "line_num": 1, "column_num": 1, "working_dir": "C:\\\\Users\\\\Ubuntu", "file_data": {"C:\\\\Users\\\\Ubuntu\\\\1": {"contents": "\\n", "filetypes": [""]}}}'
2020-08-17 00:04:11,110 - DEBUG - RX: <Response [200]>
{"python":{"executable":"C:\\Users\\Ubuntu\\AppData\\Local\\Programs\\Python\\Python38\\python.exe","version":"3.8.5"},"clang":{"has_support":false,"version":null},"extra_conf":{"path":null,"is_loaded":false},"completer":null}
2020-08-17 00:04:42,215 - DEBUG - POST b'http://127.0.0.1:7685/debug_info'
{'content-type': 'application/json', 'x-ycm-hmac': b'On2zB3jHYTaHC0e1Y7VSSJSXbH5ujOA8nVKGhs/Tci0='}
b'{"filepath": "C:\\\\Users\\\\Ubuntu\\\\1", "line_num": 1, "column_num": 1, "working_dir": "C:\\\\Users\\\\Ubuntu", "file_data": {"C:\\\\Users\\\\Ubuntu\\\\1": {"contents": "\\n", "filetypes": [""]}}}'
2020-08-17 00:04:42,218 - DEBUG - RX: <Response [200]>
{"python":{"executable":"C:\\Users\\Ubuntu\\AppData\\Local\\Programs\\Python\\Python38\\python.exe","version":"3.8.5"},"clang":{"has_support":false,"version":null},"extra_conf":{"path":null,"is_loaded":false},"completer":null}
2020-08-17 00:05:07,520 - DEBUG - POST b'http://127.0.0.1:7685/shutdown'
{'content-type': 'application/json', 'x-ycm-hmac': b'DM7q9uPJMimrIcY0domMd5BL8NhiNiprm3mqsoFlhwg='}
b''
2020-08-17 00:05:07,525 - DEBUG - RX: <Response [200]>
true

ycmd_stderr.log

2020-08-17 00:04:05,657 - DEBUG - No global extra conf, not calling method YcmCorePreload
2020-08-17 00:04:05,805 - INFO - Received ready request
2020-08-17 00:04:11,095 - INFO - Received debug info request
2020-08-17 00:04:11,096 - ERROR - Error retrieving completer debug info
Traceback (most recent call last):
File "C:\Users\Ubuntu\.vim\bundle\YouCompleteMe\third_party\ycmd\ycmd\handlers.py", line 280, in DebugInfo
response[ 'completer' ] = _GetCompleterForRequestData(
File "C:\Users\Ubuntu\.vim\bundle\YouCompleteMe\third_party\ycmd\ycmd\handlers.py", line 347, in _GetCompleterForRequestData
return _server_state.GetFiletypeCompleter( request_data[ 'filetypes' ] )
File "C:\Users\Ubuntu\.vim\bundle\YouCompleteMe\third_party\ycmd\ycmd\server_state.py", line 91, in GetFiletypeCompleter
raise ValueError( 'No semantic completer exists for filetypes: {0}'.format(
ValueError: No semantic completer exists for filetypes: ['']
2020-08-17 00:04:42,216 - INFO - Received debug info request
2020-08-17 00:04:42,216 - ERROR - Error retrieving completer debug info
Traceback (most recent call last):
File "C:\Users\Ubuntu\.vim\bundle\YouCompleteMe\third_party\ycmd\ycmd\handlers.py", line 280, in DebugInfo
response[ 'completer' ] = _GetCompleterForRequestData(
File "C:\Users\Ubuntu\.vim\bundle\YouCompleteMe\third_party\ycmd\ycmd\handlers.py", line 347, in _GetCompleterForRequestData
return _server_state.GetFiletypeCompleter( request_data[ 'filetypes' ] )
File "C:\Users\Ubuntu\.vim\bundle\YouCompleteMe\third_party\ycmd\ycmd\server_state.py", line 91, in GetFiletypeCompleter
raise ValueError( 'No semantic completer exists for filetypes: {0}'.format(
ValueError: No semantic completer exists for filetypes: ['']
2020-08-17 00:05:07,522 - INFO - Received shutdown request
2020-08-17 00:05:07,524 - DEBUG - No global extra conf, not calling method VimClose
2020-08-17 00:05:07,524 - DEBUG - No global extra conf, not calling method Shutdown

ycmd_stdout.log

serving on http://memyself:7685
puremourning commented 4 years ago

Is that the full log even after closing vim ?

How are you closing Vim ?

unavaliabl3 commented 4 years ago

sorry, I forgot to close it. Already edited.

bstaletic commented 4 years ago
2020-08-17 00:05:07,520 - DEBUG - POST b'http://127.0.0.1:7685/shutdown'
{'content-type': 'application/json', 'x-ycm-hmac': b'DM7q9uPJMimrIcY0domMd5BL8NhiNiprm3mqsoFlhwg='}
b''
2020-08-17 00:05:07,525 - DEBUG - RX: <Response [200]>

So YCM has sent the shutdown request and even received the response...

unavaliabl3 commented 4 years ago

It "sometimes" does not kill the python. image And when python hangs there, the log file is blank.

unavaliabl3 commented 4 years ago

just fond a log file from another hanging python that is not blank, but unfortunately, it has only one line

2020-08-17 00:49:03,878 - DEBUG - No global extra conf, not calling method YcmCorePreload

I don't think it's useful.

puremourning commented 4 years ago

There’s a watchdog. Do the ycmd processes exit after an hour?

unavaliabl3 commented 4 years ago

Do you mean those python processes? I have to kill them manually. I think it probably won't exit after one hour because when I first noticed them in process explorer, they have run hours.

puremourning commented 4 years ago

I mean the ones that are running ycmd. Can you check the command line of the leftover processes?. Need to know if it is ycmd or some spawn of Jedi.

For the record we do have regression tests for ycmd shut down, and unless we can repro it will be hard to diagnose.

unavaliabl3 commented 4 years ago
C:\Users\Ubuntu\AppData\Local\Programs\Python\Python38\python.exe C:\Users\Ubuntu\.vim\bundle\YouCompleteMe\python\ycm\..\..\third_party\ycmd\ycmd --port=11244 --options_file=C:\Users\Ubuntu\AppData\Local\Temp\tmpu2p44lpm --log=debug --idle_suicide_seconds=1800 --stdout=C:\Users\Ubuntu\AppData\Local\Temp\ycmd_11244_stdout_826kj_lt.log --stderr=C:\Users\Ubuntu\AppData\Local\Temp\ycmd_11244_stderr_0wkhced3.log
puremourning commented 4 years ago

And that’s been wedged for more than 1800 seconds?

unavaliabl3 commented 4 years ago

20min

puremourning commented 4 years ago

Let us know if it doesn’t die after 1 hour as that’s an important data point.

bstaletic commented 4 years ago

--idle_suicide_seconds=1800 means 30 minutes.

unavaliabl3 commented 4 years ago

they dead. does that counter stop when I put the computer into sleep?