antoinemadec / coc-fzf

fzf :heart: coc.nvim
390 stars 28 forks source link

nvim crashes on "CocFzfList symbols" after commit 2d9deb2a3b05a0c09f01edda0a4abd542cb3eebd #109

Closed r7vme closed 3 years ago

r7vme commented 3 years ago

Environment

Features: +acl +iconv +tui See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info


My plugins (`neoclide/coc.nvim` bug reproduces both on master and release)

call plug#begin('~/.config/nvim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}
Plug 'junegunn/fzf.vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'antoinemadec/coc-fzf', {'branch': 'release'}
call plug#end()


# Describe the Bug

More like raise awareness than bug in coc-fzf.

I see constant crashes with `free(): double free detected in tcache 2 [1]    81777 abort (core dumped)  nvim tmp/1.cpp`, when `CocFzfList symbols` executed for at least two times. I was able to localize bug to this commit https://github.com/antoinemadec/coc-fzf/commit/2d9deb2a3b05a0c09f01edda0a4abd542cb3eebd . When I revert this commit all works fine.

~~After playing around I think the problem in call to `coc#util#get_config('list.source.symbols')`. So I decided to try to update coc.nvim to master branch. It seems fixes the problem.~~

In short, workarounds:
1. `git revert 2d9deb2a3b05a0c09f01edda0a4abd542cb3eebd`
2. ~~or use master branch of coc.nvim `Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}`~~ (Does not really help)

# To Reproduce
## **Minimal** vimrc

See above.

## Steps to Reproduce

1.cpp

```cpp
int main()
{
  return 1;
}
  1. nvim 1.cpp
  2. CocFzfList symbols then enter
  3. CocFzfList symbols then enter
  4. wait 2-3 secods
  5. crash with free(): double free detected in tcache 2 [1] <PID> abort (core dumped) nvim 1.cpp

Expected Behavior

No crashes on CocFzfList symbols

More info

I use Arch linux, but I also see exactly the same behavior in Ubuntu 18.04 based docker environments. I also tried different clangd versions, but seems it's not related to clangd

Coredump for one of the crashes

                Stack trace of thread 81922:
                #0  0x00007f1821402d22 raise (libc.so.6 + 0x3cd22)
                #1  0x00007f18213ec862 abort (libc.so.6 + 0x26862)
                #2  0x00007f1821444d28 __libc_message (libc.so.6 + 0x7ed28)
                #3  0x00007f182144c92a malloc_printerr (libc.so.6 + 0x8692a)
                #4  0x00007f182144e408 _int_free (libc.so.6 + 0x88408)
                #5  0x00007f18214519e8 __libc_free (libc.so.6 + 0x8b9e8)
                #6  0x00005646788f01ec vars_clear_ext (nvim + 0xf41ec)
                #7  0x00005646789349a9 free_unref_funccal (nvim + 0x1389a9)
                #8  0x00005646788f184f garbage_collect (nvim + 0xf584f)
                #9  0x0000564678a30ea8 os_inchar (nvim + 0x234ea8)
                #10 0x0000564678abc11f state_enter (nvim + 0x2c011f)
                #11 0x00005646789f563c normal_enter (nvim + 0x1f963c)
                #12 0x0000564678872141 main (nvim + 0x76141)
                #13 0x00007f18213edb25 __libc_start_main (libc.so.6 + 0x27b25)
                #14 0x00005646788733fe _start (nvim + 0x773fe)

                Stack trace of thread 81923:
                #0  0x00007f18214c492e epoll_wait (libc.so.6 + 0xfe92e)
                #1  0x00007f18217fc665 n/a (libuv.so.1 + 0x22665)
                #2  0x00007f18217e8897 uv_run (libuv.so.1 + 0xe897)
                #3  0x0000564678ae6397 n/a (nvim + 0x2ea397)
antoinemadec commented 3 years ago

Thanks for the report, i have 3 questions.

Q1. Do you have the same crash with a nightly build of Neovim ?

Q2. Your minimal vimrc includes a bunch of plugins like NerdTree etc. Could you please remove them and tell me if you still observe the crash? If so, please provide the new minimal vimrc.

Q3. What does you coc-settings.json look like as far as the excludes are concerned?

r7vme commented 3 years ago

@antoinemadec

Q1. Do you have the same crash with a nightly build of Neovim ?

Checking, post update later

Q2. Your minimal vimrc includes a bunch of plugins like NerdTree etc. Could you please remove them and tell me if you still observe the crash? If so, please provide the new minimal vimrc.

Yes, I can observe same w/

call plug#begin('~/.config/nvim/plugged')                                                                                                                                                                                             
Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}                                                                                                                                                
Plug 'junegunn/fzf.vim'                                                                                                                                                                                                               
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }                                                                                                                                                                                   
Plug 'antoinemadec/coc-fzf', {'branch': 'release'}                                                                                                                                                                                                                                                                                                                                                                                             
call plug#end()   

Q3. What does you coc-settings.json look like as far as the excludes are concerned?


cat .config/nvim/coc-settings.json 
{
"coc.preferences.extensionUpdateCheck": "weekly",
"diagnostic.refreshOnInsertMode": true,
"markdownlint.onChange": false
}
r7vme commented 3 years ago

@antoinemadec I see same error w/ nightly neovim

nvim --version 
NVIM v0.6.0-dev+566-g4174244d8
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az68-184

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info
weirdan commented 3 years ago

I'm seeing the same crash. Should this be reported on neovim repo though?

Thanks for the workaround @r7vme, this crash is quite annoying.

antoinemadec commented 3 years ago

@r7vme @weirdan , nvim should never crash, that's for sure.

However, I really don't trust some of the code that I added in 2d9deb2. For instance, this:

symbol_excludes = eval(args.symbol_excludes)

If the crash comes from there, maybe a brutal try except could fix this ? I will try to reproduce and work around this bug this weekend.

antoinemadec commented 3 years ago

@r7vme @weirdan this was definitely a super weird issue with neovim. Do you think one of you could create an issue on the neovim repo?

weirdan commented 3 years ago

I'm sure they would ask for a minimal reproducer that I won't be able to come up with.

antoinemadec commented 3 years ago

No pb, I will take care of it then. Thanks anyway for the precise reporting and for finding the commit causing the regression!

r7vme commented 3 years ago

@antoinemadec appreciate that and thanks for the plugin

antoinemadec commented 3 years ago

https://github.com/neovim/neovim/issues/16287