Alfonso Giron Alfonso Giron - 1 month ago 43
Ruby Question

Rails 5 Bug (Segmentation fault)

Getting an error in the terminal running any rails command, for example 'rails test', after I modify a file in my project such as the model file 'users.rb' or the controller file 'users_controller.rb'. The bug is 'fixed' if I run 'spring stop' to restart the spring server. But it comes up every time I modify a file. Here is the initial message of the error/bug:

[sample_app (modeling-users)]$ time rails test
Running via Spring preloader in process 43345
/Users/AlfonsoGiron/.rvm/gems/ruby-2.3.1@global/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/sqlite3_adapter.rb:27: [BUG] Segmentation fault at 0x00000000000110
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]


The error goes on for thousands of lines. Here is a small piece of the beginning of it:

-- Control frame information -----------------------------------------------
c:0072 p:---- s:0285 e:000284 CFUNC :initialize
c:0071 p:---- s:0283 e:000282 CFUNC :new
c:0070 p:0183 s:0278 e:000277 METHOD /Users/AlfonsoGiron/.rvm/gems/ruby-2.3.1@global/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/sqlite3_adapter
c:0069 p:0028 s:0271 e:000270 METHOD /Users/AlfonsoGiron/.rvm/gems/ruby-2.3.1@global/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connec
c:0068 p:0027 s:0268 e:000267 METHOD /Users/AlfonsoGiron/.rvm/gems/ruby-2.3.1@global/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/abstract/connec


And here is the last few lines:

1696 /Users/AlfonsoGiron/.rvm/gems/ruby-2.3.1@global/gems/activesupport-5.0.0.1/lib/active_support/testing/stream.rb
1697 /Users/AlfonsoGiron/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0.1/lib/rails/generators/testing/behaviour.rb
1698 /Users/AlfonsoGiron/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0.1/lib/rails/generators/testing/setup_and_teardown.rb
1699 /Users/AlfonsoGiron/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0.1/lib/rails/generators/testing/assertions.rb
1700 /Users/AlfonsoGiron/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/x86_64-darwin15/io/console.bundle
1701 /Users/AlfonsoGiron/.rvm/gems/ruby-2.3.1@global/gems/thor-0.19.1/lib/thor/shell/basic.rb
1702 /Users/AlfonsoGiron/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0.1/lib/rails/generators/test_case.rb
1703 /Users/AlfonsoGiron/.rvm/gems/ruby-2.3.1@global/gems/activesupport-5.0.0.1/lib/active_support/testing/autorun.rb
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html


Basically every line is referring to '.rvm/gems/' etc. Clearly it's a rvm/gems issue? I've run 'bundle update' and reinstalled my gems to no avail. If anything, suggestions on the cleanest way to uninstall/reinstall Ruby/Rails? Thinking that may be a solution but would want to do it properly. Thanks.

Answer

It looks like a defect with the sqlite3 gem.. See bug report here: https://bugs.ruby-lang.org/issues/12781 and https://bugs.ruby-lang.org/issues/12795

It does not appear there is a fix yet.. I'm having this issue as well, initially I was able to run brew update and then bundle update in a new terminal window which allowed me to call .connection on my models and get the console access again.. today this is still working but a very labourious process.