hrsh7th / nvim-cmp

A completion plugin for neovim coded in Lua.
MIT License
8.05k stars 399 forks source link

Segmentation fault when writing "// 1." in c like languages #1021

Closed nikolightsaber closed 2 years ago

nikolightsaber commented 2 years ago

FAQ

Announcement

Minimal reproducible full config

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug "hrsh7th/cmp-path"
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require "cmp"
cmp.setup {
  snippet = {
    expand = function(args)
      vim.fn["vsnip#anonymous"](args.body)
    end,
  },

  mapping = {
    ['<CR>'] = cmp.mapping.confirm({ select = true })
  },

  sources = {
    { name = "buffer" },
    { name = "path" },
  },
}
EOF

Description

When I go into a c like file and start writing the comment //1. i get a segmentation fault

I'm pretty sure it is the dot that is doing it.

I feel it is an issue with cmp-path in combination with another cmp source like buffer.

Screenshot from 2022-06-02 20-59-50

I use the lastest neovim from master 0.8-dev (commit: e6652821bd32e4ff8d62a0b67fc2041a5f41e252)

Do I need to make an issue in the main neovim repo. This seems serious.

Steps to reproduce

Go into any c like file and start wring // 1. and the issue should happen.

With the config above of course.

Expected behavior

No segmentation fault.

Actual behavior

Segmentation fault

Additional context

No response

smjonas commented 2 years ago

Thank you, it's reassuring to confirm that I'm not the only one who has encountered this issue recently. I was about to open a similar issue a few minutes ago but wasn't sure if I reproduced it correctly. I am also on Neovim nightly. For me the segmentation fault happens when typing '*./%.rc in a buffer (sometimes it does not crash immediately). When nvim-cmp is uninstalled the issue does not occur.

See this GIF:

https://user-images.githubusercontent.com/40792180/171723620-59be4c0d-a504-4575-9152-fbe7bd3b1233.mp4

Could this be the underlying issue: https://github.com/luvit/luv/issues/603? If yes, it seems to be already fixed by https://github.com/neovim/neovim/pull/18834.

nikolightsaber commented 2 years ago

Hi thanks for the comment !

I've updated my neovim this morning and indeed the problem seems fixed for me. https://github.com/neovim/neovim/pull/18834. seems to have don the job

I'll close the issue since it is fixed for me

if it is not fixed for you feel free to re-open

smjonas commented 2 years ago

Fixed for me as well after upgrading to latest master :+1: