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

Seg fault on Command-T #215

Closed
benmoss opened this issue Jul 6, 2011 · 41 comments
Closed

Seg fault on Command-T #215

benmoss opened this issue Jul 6, 2011 · 41 comments

Comments

@benmoss
Copy link

@benmoss benmoss commented Jul 6, 2011

This is somewhat identical to #109 but that issue is closed and I can't reopen it. I'm on Snow Leopard.

Open a project, hit cmd-T, and it crashes and in console reports

Vim: Caught deadly signal SEGV
Vim: Finished.
121H3;0M                               
Error detected while processing function <SNR>63_NetrwBookHistSave:
line    8:
E36: Not enough room

I tried @danboy's solution in that thread and it stopped mvim from crashing on load, but cmd-T still crashes.

@rainerborene
Copy link

@rainerborene rainerborene commented Jul 6, 2011

Go to the command-t folder and type: git checkout 1.2.1.

@benmoss
Copy link
Author

@benmoss benmoss commented Jul 6, 2011

error: pathspec 'ruby/command-t/1.2.1' did not match any file(s) known to git.
@CodeOfficer
Copy link

@CodeOfficer CodeOfficer commented Jul 12, 2011

The Janus/Command-T plugin has been busted for a long time now if using 1.9.2 as your default ruby. I can usually at least get MacVim to start up again by cd'ing into ~/.vim/ruby/command-t and running 'ruby extconf.rb && make' but that doesn't fix the plugin.

@benmoss
Copy link
Author

@benmoss benmoss commented Jul 16, 2011

I believe the solution to this is to compile Command-T with 1.8.7

@benmoss benmoss closed this Jul 16, 2011
@CodeOfficer
Copy link

@CodeOfficer CodeOfficer commented Jul 16, 2011

Been there, done that, doesn't work still.

@benmoss benmoss reopened this Jul 16, 2011
@pivotal-casebook
Copy link

@pivotal-casebook pivotal-casebook commented Jul 21, 2011

You need to make sure that the version of ruby you compiled your vim/macvim binary with matches.

So for instance:

$ rvm use system
$ brew install macvim
(compile command-t also using system ruby)

any mismatch will cause segfaults.

See the note here: http://www.vim.org/scripts/script.php?script_id=3025

Note that Command-T requires a version of VIM with Ruby support enabled, and it must be compiled using the same version of Ruby that Vim itself links against. For more details see the documentation:

I would close this out as not a bug to be fixed in command-t. Might be nice if the makefile detected what version of ruby your vim was built against though.

@CodeOfficer
Copy link

@CodeOfficer CodeOfficer commented Jul 21, 2011

Thanks for the insight! Sounds like this may address the issue. I'll check it out later today.

@mikesells
Copy link

@mikesells mikesells commented Jul 25, 2011

pivotal-casebook's instructions fixed it for me. Thanks!

@ghost
Copy link

@ghost ghost commented Aug 4, 2011

I did the whole install from system, but now it randomly crashes, sometimes with "ILL" and sometimes with "SEGV".

@philipkobernik
Copy link

@philipkobernik philipkobernik commented Aug 5, 2011

pivotal-casebook's instructions worked for me as well. Thanks!

@dx7
Copy link
Contributor

@dx7 dx7 commented Aug 29, 2011

perfect explanation from pivotal-casebook. Thanks!

@philtr
Copy link

@philtr philtr commented Oct 5, 2011

+1 to @pivotal-casebook's solution. Thanks!

@fphilipe
Copy link

@fphilipe fphilipe commented Oct 6, 2011

@pivotal-casebook's solution worked, but calling mvim only works when I'm on the system ruby, else I get the SEGV when launching. Any solution for this?

@madtrick
Copy link

@madtrick madtrick commented Nov 26, 2011

I would like to suggest to change the code used to install command_t plugin.

Why?
When I installed MacVim I was using ruby1.9.2 as my choice, so vim was compiled against it. Now, when I use Janus and install command_t with it I got a SEG_FAULT error when running Vim. That's because of the following.

This is the code shipped with janus used to install command_t

vim_plugin_task "command_t",        "http://s3.wincent.com/command-t/releases/command-t-1.2.1.vba" do
  Dir.chdir "ruby/command-t" do
    if File.exists?("/usr/bin/ruby1.8") # prefer 1.8 on *.deb systems
      sh "/usr/bin/ruby1.8 extconf.rb"
    elsif File.exists?("/usr/bin/ruby") # prefer system rubies
      sh "/usr/bin/ruby extconf.rb"
    elsif `rvm > /dev/null 2>&1` && $?.exitstatus == 0
      sh "rvm system ruby extconf.rb"
    elsif `rbenv > /dev/null 2>&1` && $?.exitstatus == 0
      sh "RBENV_VERSION=system ruby extconf.rb"
    end
    sh "make clean && make"
  end
end

When this code is run it looks for versions of ruby installed on the system. First looks for systemwide installations

    if File.exists?("/usr/bin/ruby1.8") # prefer 1.8 on *.deb systems
      sh "/usr/bin/ruby1.8 extconf.rb"
    elsif File.exists?("/usr/bin/ruby") # prefer system rubies
      sh "/usr/bin/ruby extconf.rb"

And if none of that exists then it looks for rvm or rbenv:

    if `rvm > /dev/null 2>&1` && $?.exitstatus == 0
      sh "rvm system ruby extconf.rb"
    elsif `rbenv > /dev/null 2>&1` && $?.exitstatus == 0
      sh "RBENV_VERSION=system ruby extconf.rb"

This order (first systemwide then rvm or rbenv) causes on my system command_t to be compiled with "/usr/bin/ruby" which is ruby1.8.7 rather than with ruby1.9.2 which is managed by rvm. This results in a SEG FAULT when running vim.

So, What's what I suggest?

I suggest checking before for rvm and rbenv and if they fail, then go for systemwide rubies. Like this:

vim_plugin_task "command_t",        "http://s3.wincent.com/command-t/releases/command-t-1.2.1.vba" do
  Dir.chdir "ruby/command-t" do
    if `rvm > /dev/null 2>&1` && $?.exitstatus == 0
      sh "rvm system ruby extconf.rb"
    elsif `rbenv > /dev/null 2>&1` && $?.exitstatus == 0
      sh "RBENV_VERSION=system ruby extconf.rb"
    elsif File.exists?("/usr/bin/ruby1.8") # prefer 1.8 on *.deb systems
      sh "/usr/bin/ruby1.8 extconf.rb"
    elsif File.exists?("/usr/bin/ruby") # prefer system rubies
      sh "/usr/bin/ruby extconf.rb"
    end
    sh "make clean && make"
  end
end
@kalbasit
Copy link
Member

@kalbasit kalbasit commented Nov 27, 2011

This has already been taken care of in the experimental branch, short version: make sure you are using system ruby and not one installed via rvm or rbenv before compiling MacVim (which you should install via Homebrew c.f the Readme) and use the same ruby when running rake

@kalbasit kalbasit closed this Nov 27, 2011
@dudleyf
Copy link

@dudleyf dudleyf commented Dec 3, 2011

I still get a segfault on the experimental branch running mvim. I installed with the system ruby as per the instructions, but when I switch back to 1.9.3, mvim segfaults.

@kalbasit
Copy link
Member

@kalbasit kalbasit commented Dec 3, 2011

How did you install MacVIm ?

@dudleyf
Copy link

@dudleyf dudleyf commented Dec 3, 2011

rvm use system
brew install macvim
@kalbasit
Copy link
Member

@kalbasit kalbasit commented Dec 3, 2011

ok and after that, did you re-compile command-t ? Try

cd ~/.vim
rm -rf janus/vim/tools/command-t
git checkout HEAD -- janus/vim/tools/command-t
rake
@kalbasit
Copy link
Member

@kalbasit kalbasit commented Dec 3, 2011

Also make sure that rvm has parsed .rvmrc before running rake like I showed above, you can see that by running rvm use in the ~/.vim folder

@dudleyf
Copy link

@dudleyf dudleyf commented Dec 3, 2011

Same result, segfault after switching back to 1.9.

@kalbasit
Copy link
Member

@kalbasit kalbasit commented Dec 3, 2011

Very weird I never had this issue even after following this

/cc @adrianrego

@kalbasit kalbasit reopened this Dec 3, 2011
@adrianrego
Copy link
Member

@adrianrego adrianrego commented Dec 3, 2011

That is weird. Are you using the latest version of RVM and the macvim formula in homebrew?

@dudleyf
Copy link

@dudleyf dudleyf commented Dec 3, 2011

rvm 1.10.0-pre and brew updated this morning.

@adrianrego
Copy link
Member

@adrianrego adrianrego commented Dec 3, 2011

i'd try removing macvim and walking through each step of the process making sure along the way that rvm is using the system ruby.

cd ~ brew remove macvim brew cleanup rvm use system brew install macvim git clone -b experimental git://github.com/carlhuda/janus.git .vim cd .vim rvm use system rake

@dudleyf
Copy link

@dudleyf dudleyf commented Dec 3, 2011

Nope. Same thing. Is there any way to see which Ruby macvim was compiled with?

@kalbasit
Copy link
Member

@kalbasit kalbasit commented Dec 3, 2011

Yes there is, I'm not using Mac, so make sure to get the correct path of the macvim binary, I would go for brew prefix macvim Also make sure there's no MacVim.app in your /Applications and ~/Applications folders

ldd /path/to/vim | grep ruby
@dudleyf
Copy link

@dudleyf dudleyf commented Dec 3, 2011

It's spelled otool -L on the Mac, but it does show it's using the system Ruby:

dudley@kima macvim/7.3-63 :> otool -L MacVim.app/Contents/MacOS/Vim | grep ruby
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/libruby.1.dylib (compatibility version 1.8.0, current version 1.8.7)
@kalbasit
Copy link
Member

@kalbasit kalbasit commented Dec 3, 2011

and where is this MacVim.app ? is it in /Applications or ~/Applications

@dudleyf
Copy link

@dudleyf dudleyf commented Dec 3, 2011

It's in /usr/local/Cellar/macvim/7.3-63/MacVim.app. There are no other MacVims in /Applications or ~/Applications

@kalbasit
Copy link
Member

@kalbasit kalbasit commented Dec 3, 2011

Okay so the MacVim is good, now try finding out which version Command-T is compiled with, here's the output on my archlinux box (which uses Ruby 1.9.3 as system-wide ruby)

$ ldd ~/.vim/janus/vim/tools/command-t/ruby/command-t/ext.so
        linux-vdso.so.1 =>  (0x00007fff2a8f9000)
        libruby.so.1.9 => /usr/lib/libruby.so.1.9 (0x00007f8ed7c9e000)
        libc.so.6 => /lib/libc.so.6 (0x00007f8ed7917000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00007f8ed76f9000)
        librt.so.1 => /lib/librt.so.1 (0x00007f8ed74f1000)
        libdl.so.2 => /lib/libdl.so.2 (0x00007f8ed72ed000)
        libcrypt.so.1 => /lib/libcrypt.so.1 (0x00007f8ed70b5000)
        libm.so.6 => /lib/libm.so.6 (0x00007f8ed6e33000)
        /lib/ld-linux-x86-64.so.2 (0x00007f8ed82e3000)

Notice where the ruby points ? So on my system both vim and command-t uses the same ruby version, if you're in the same situation then I start looking for something else causing the Segfault, @adrianrego you agree ?

@dudleyf
Copy link

@dudleyf dudleyf commented Dec 3, 2011

Yep, looks like command-t is using the same ruby:

dudley@kima ~/.vim :> otool -L ~/.vim/janus/vim/tools/command-t/ruby/command-t/ext.bundle                                     experimental//
/Users/dudley/.vim/janus/vim/tools/command-t/ruby/command-t/ext.bundle:
        /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/libruby.1.dylib (compatibility version 1.8.0, current version 1.8.7)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
@kalbasit
Copy link
Member

@kalbasit kalbasit commented Dec 3, 2011

Do you have any custom plugin installed ?

Please try this

cd ~/.vim
for submodule in `git submodule | grep -v core | awk '{print $2}'`; do
  echo "call janus#disable_plugin('`basename ${submodule}`')" >> ~/.vimrc.before;
done

The command above will disable every plugin provided by Janus except the core (which is pathogen and settings, which I'm sure won't be causing any segfaults) if MacVim did start without problems try removing plugins from ~/.vimrc.before one by one and starting MacVim afterwards so you could narrow down the problem, start with command-t, if you enable command-t and macvim starts then it is not the source of the problem and you should continue on to the next plugin.

@dudleyf
Copy link

@dudleyf dudleyf commented Dec 3, 2011

It's hammer.

@kalbasit
Copy link
Member

@kalbasit kalbasit commented Dec 3, 2011

Hammer ? Weird

Do you have both github-markup and redcarpet installed on the system-wide ruby? You can find that out using

rvm use system
gem search github-markup
gem search redcarpet

@adrianrego did you ever have segfaults because of Hammer ?

@dudleyf
Copy link

@dudleyf dudleyf commented Dec 3, 2011

It's a known issue in Hammer. Apparently rvm causes the macvim ruby to load the wrong gem versions:
https://github.com/robgleeson/hammer.vim/issues/22
Thanks for helping me track it down!

@kalbasit
Copy link
Member

@kalbasit kalbasit commented Dec 3, 2011

Oh We've encountered this before, please follow the Rvm Wiki page, let me know if it fixes your issue

@dudleyf
Copy link

@dudleyf dudleyf commented Dec 3, 2011

The function on that page ends up calling /usr/bin/vim instead of mvim. This one from the hammer issue works for me:

mvim() {
  (unset GEM_PATH GEM_HOME; command mvim "$@")
}
@kalbasit
Copy link
Member

@kalbasit kalbasit commented Dec 3, 2011

Oops sorry about that, the function had vim hardcoded, I did not notice it, thanks for finding that out, would you mind trying it just to make sure the function works? Thank you

@dudleyf
Copy link

@dudleyf dudleyf commented Dec 3, 2011

Yep. Works like a charm, now. Thanks.

@kalbasit
Copy link
Member

@kalbasit kalbasit commented Dec 3, 2011

Thank you

@kalbasit kalbasit closed this Dec 3, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.