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

SIGSEGV during tab completion from nvim command (vim not installed) #7344

Closed
planet36 opened this issue Sep 20, 2020 · 2 comments
Closed

SIGSEGV during tab completion from nvim command (vim not installed) #7344

planet36 opened this issue Sep 20, 2020 · 2 comments
Labels
bug Something that's not working as intended regression Something that used to work, but was broken, especially between releases
Milestone

Comments

@planet36
Copy link

Environment

fish --version

fish, version 3.1.2

uname -a

Linux archvm 5.8.10-arch1-1 #1 SMP PREEMPT Thu, 17 Sep 2020 18:01:06 +0000 x86_64 GNU/Linux

echo $PATH

/usr/local/sbin /usr/local/bin /usr/bin /usr/bin/site_perl /usr/bin/vendor_perl /usr/bin/core_perl

alias -s

alias vim 'FOO= vim'

Background

I'm a new user of fish, and I'm converting my bash aliases to be in config.fish.

I copied an alias for vim, even though it isn't installed (I use neovim). The alias is recursive, but I didn't bother to change it because, again, vim isn't installed.

Doing any tab completion for a nvim command results in a crash.

Steps to reproduce

  • Install neovim.
  • Do not have vim installed vim.
  • Create this alias (that's been simplified from my original)
    alias vim 'FOO= vim'
  • In fish, at $HOME, type nvim .co then TAB to attempt tab completion.

Outcome

The shell appears to freeze for about a second, then it crashes. This is printed if it was opened from another shell:

fish: 'fish' terminated by signal SIGSEGV (Address boundary error)

strace

An strace has this repeated for over 20,000 lines

access("/usr/local/sbin/vim", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/local/bin/vim", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/bin/vim", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/bin/site_perl/vim", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/bin/vendor_perl/vim", X_OK) = -1 ENOENT (No such file or directory)
access("/usr/bin/core_perl/vim", X_OK) = -1 ENOENT (No such file or directory)

Before finally printing this

--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x7ffcfd9b3fe8} ---
+++ killed by SIGSEGV (core dumped) +++

@ridiculousfish
Copy link
Member

Awesome find! Repros easily for me on master.

It's a native (C++) stack overflow. I think this is fallout from adding the FOO= syntax, we have an acknowledged hack for completions which wrap other completions and it's falling down here. Probably this needs to be implemented properly.

@ridiculousfish ridiculousfish added this to the fish 3.2.0 milestone Sep 21, 2020
@krobelus
Copy link
Member

Thanks for reporting!

To compute completions for FOO= vim we call complete() for vim with a new context (which has the FOO variable set). Hence the infinite recursion if vim should be completed as FOO= vim.

We actually have a similar cycle detection like that for the complete builtin. Maybe we can move that cycle detection to complete(), then we'd print an error message.
(Currently we don't report an error if walk_wrap_chain_recursive runs into cycles.)

@krobelus krobelus added bug Something that's not working as intended regression Something that used to work, but was broken, especially between releases labels Sep 21, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something that's not working as intended regression Something that used to work, but was broken, especially between releases
Projects
None yet
Development

No branches or pull requests

3 participants