Segmentation fault on ruby installed with rbenv - ruby-on-rails

I use ruby 1.9.3 in a rails application. I successfully installed ruby using rbenv and gcc 4.2 on OSX Yosemite and could install dependencies with bundler.
When I try to setup the database I get the following error:
bundle exec rake db:setup
foo already exists
foo_test already exists
ruby(31773,0x7fff79ac7300) malloc: *** error for object 0x7fe00a8c0dc8: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
[1] 31773 abort bundle exec rake db:setup
After the first time I get a different error message:
$ bundle exec rake db:setup
-- create_table("foo", {:force=>true})
-> 0.0241s
...
-- create_table("bar", {:force=>true})
-> 0.0241s
/Users/jedi/code/foo/.bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/migration.rb:601: [BUG] Segmentation fault
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-darwin14.3.0]
-- Control frame information -----------------------------------------------
c:0062 p:0012 s:0220 b:0220 l:000219 d:000219 METHOD /Users/jedi/code/foo/.bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/migration.rb:601
c:0061 p:0071 s:0216 b:0214 l:000195 d:000213 BLOCK /Users/jedi/code/foo/.bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/migration.rb:461
c:0060 p:0005 s:0212 b:0212 l:000201 d:000211 BLOCK /Users/jedi/code/foo/.bundle/ruby/1.9.1/gems/activerecord-3.2.18/lib/active_record/migration.rb:438
...
-- Ruby level backtrace information ----------------------------------------
/Users/jedi/code/foo/.bundle/ruby/1.9.1/bin/rake:23:in `<main>'
/Users/jedi/code/foo/.bundle/ruby/1.9.1/bin/rake:23:in `load'
...
[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
I tried updating to ruby 2.0.0 and compiling ruby using clang, but always got the same. Any ideas?

This was caused by an incorrect version of zeromq being installed on the computer. We were using a gem that targets zeromq 3 but had version 4 installed.
I arrived to this conclusion after some binary search removing and adding dependencies from the Gemfile. Downgrading zeromq did the job.
To me it's still a mistery why the error report is so misleading, but problem solved.

Related

Segmentation fault on M1 running a Rails System Test

I'm running a system test in a Rails app on a MacBook M1 Big Sur OS and it's giving me a segmentation fault error.
I'm using Ruby 2.7.1 installed via rbenv
➜ which ruby
/Users/sc/.rbenv/shims/ruby
➜ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [-darwin20]
Now, the issue comes whenever I run a rails system test.
Our system tests are congigured with the headless_chrome Capybara driver, which has probably (not sure about this) something to do with the segmentation fault error.
This is what I get when I run the test:
[BUG] Segmentation fault at 0x000000001b543e20
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [-darwin20]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
Don't forget to include the above Crash Report log file in bug reports.
-- Control frame information -----------------------------------------------
c:0001 p:---- s:0003 e:000002 (none) [FINISH]
-- Other runtime information -----------------------------------------------
* Loaded script: rails_test
* Loaded features:
0 enumerator.so
1 thread.rb
2 rational.so
3 complex.so
4 ruby2_keywords.rb
5 /Users/sc/.rbenv/versions/2.7.1/lib/ruby/2.7.0/-darwin20/enc/encdb.bundle
6 /Users/sc/.rbenv/versions/2.7.1/lib/ruby/2.7.0/-darwin20/enc/trans/transdb.bundle
7 /Users/sc/.rbenv/versions/2.7.1/lib/ruby/2.7.0/-darwin20/rbconfig.rb
8 /Users/sc/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/compatibility.rb
9 /Users/sc/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/defaults.rb
10 /Users/sc/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/deprecate.rb
And many more lines...
Any ideas on what's causing this error?
This happens because of a bug in Enumerator#next, happening in ruby 2.7.1 on Apple M1. Capybara uses it in Capybara::Result class.
The simpleset irb snippet to ensure this is your case is [1,2,3].to_enum.next:
irb(main):003:0> [1,2,3].to_enum.next
[BUG] Segmentation fault at 0x0000000004809020
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [-darwin20]
The best solution is to upgrade ruby version to 2.7.3, which does not have this bug.
(If you need to run the tests quickly and solve the core problem later, you can edit capybara's result.rb locally, as a stupid temporary workaround. But I strongly recommend to upgrade ruby version asap)
UPD: I have posted a bug report in a ruby bug tracker.
I ran into the same problem when running my tests. I was helped by the Ruby update to 2.7.3

Error running Rails server on OS 10.10.2

Versions
Mac OS: OSX 10.10.2
Ruby: 2.2.1p85
Rails: 4.2.0
Context
I am following the "Install Rails" tutorial online at www.installrails.com. Finally made it through after encountering many errors. I am on the last step of creating a sample app, which it worked fine, and then running the server. Now, I run into another error.
Errors
Here is what I am seeing:
/Users/Work/.rvm/gems/ruby-2.2.1/gems/json-1.8.2/lib/json/ext/parser.bundle: [BUG] Segmentation fault at 0x00000000000418
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
-- Control frame information -----------------------------------------------
*A lot of information listed here*
-- Ruby level backtrace information ----------------------------------------
*A lot of information listed here*
-- Machine register context ------------------------------------------------
*A lot of information listed here*
-- C level backtrace information -------------------------------------------
*A lot of information listed here*
-- Other runtime information -----------------------------------------------
* Loaded script: bin/rails
* Loaded features:
*And then a long list of files listed here*
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
Don't forget to include the above Crash Report log file.
For details: http://www.ruby-lang.org/bugreport.html
Abort trap: 6
Help
Now, I am wondering if it is the json gem that is causing a problem?
Let me know if you need any of the removed information. The bug report was really long so I removed the codes where it says A lot of information listed here for brevity.
Per a suggestion by #maxd, I ended up having to uninstall and reinstall ruby.
Here is the process I followed.
I uninstalled Ruby with command line rvm remove 2.2.1
I reinstall 2.2.1 with the command line rvm install 2.2.1
Then I reinstalled rails with command line sudo gem install rails
Then I used bundle install to reinstall missing gems
Next, I used gem install rubygems-update to update Rubygems from 2.0.14 to 2.1.
Then I reset gems to pristine condition with gem pristine --all.
Then for some reason I had to rerun bundle install because actionmailer 4.2.0 was no longer showing as being installed, even though it was in the list after the first bundle install.
Finally running rails -v gave me an output of Rails 4.2.0 instead of error codes.
So, I ran rails server and all is well.
I solved this problem. But I not certain this is a GOOD way.
first, I reinstalled ruby. since, I looks like version problem as I see.
rvm reinstall all
and gem install rails. After this process, I can run server with rails server command.
I hope this could be a your solution too. Have a good day :D
I was experiencing the same problem in my mac mini(M1). The following solution worked for me found in the developer forum.
sudo arch -x86_64 gem install ffi
Then
arch -x86_64 pod install

rubygems/custom_require.rb:36:in `require': cannot load such file -- script/../config/boot (LoadError)

I am trying to execute a Capistrano task that requires resetting a database but when I come upon a particular line of code I receive the error illustrated in the title. Here is the complete error message:
RAILS_ENV=testing script/runner 'Account.all.each(&:reindex_person)' exit status: 1
cd /var/local/openhub/current && RAILS_ENV=testing script/runner
'Account.all.each(&:reindex_person)' stdout: Nothing written
cd /var/local/openhub/current && RAILS_ENV=testing script/runner
'Account.all.each(&:reindex_person)' stderr:
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in
`require': cannot load such file -- script/../config/boot (LoadError)
As you can see in the message, the error is triggered by the script/runner command. To better understand the issue that I am having, I have turned to these three stack overflow questions with roughly the same error:
cannot load such file — script/../config/boot (LoadError) after OSX Mavericks
no such file to load — rubygems (LoadError)
Strange inability to require config/boot
I am using
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
Rails 2.3.18
From the suggestions in the questions, it seems that the problem was that multiple versions of ruby were installed in the OS and that by removing them until one remained, the problem could be fixed. That's not the case with me. When I run which -a ruby I get the output /usr/bin/ruby and I have only ruby 1.9.3 installed.
However, I noticed this little oddity in my system. /usr/bin/ruby1.9.1
This must be the error that I am having. The inconsistency is what I believe is causing the error, but it is strange to me because I am able to run script/server and script/console just fine.
What would be the solution for this, to my knowledge the system that I use does not have rvm. Do I need to uninstall ruby and re-install version 1.9.3? I am trying to better understand what problem I'm having because as it stands I am still a novice programmer and I'm a little hesitant to breaking my entire testing system by messing with the internals without a complete understanding of what is taking place. Help would be much appreciated. Thanks.

rails c : [FATAL] failed to allocate memory

I am getting this error when trying to run my rails app :
[FATAL] failed to allocate memory
This is on a new mac book air with lion. It used to run ok, I don't really know what I changed...
I also get this error when doing rake db:drop :
[BUG] Segmentation fault
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin11.0.1]
-- control frame ----------
c:0001 p:0000 s:0002 b:0002 l:000498 d:000498 TOP
---------------------------
-- C level backtrace information -------------------------------------------
[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
Abort trap: 6
someone knows how I can fix this? Thanks!

Configuring and running Ruby-On-Rails migrations

I'm (completely) new to ROR and have got an application to maintain and upgrade. I've the source code and am trying to build database using db:migrate rake command. I've started using Aptana Studio for the development. When I run dg:migrate I get following errors:
rake db:migrate
(in G:/Projects/.../.../trunk)
MissingSourceFile no such file to load -- rcov/rcovtask
WARNING: rcov tests won't work
Looking for release_type overrides ...
=> Loading G:/Projects/.../.../trunk/config/release_type_config.rb
DEPRECATION WARNING: ActiveRecord::Base.allow_concurrency=has been deprecated and
no longer has any effect. Please remove all references to allow_concurrency=..
(called from allow_concurrency= at D:/Ruby/lib/ruby/gems/1.8/gems/
activerecord-2.3.5/lib/active_record/connection_adapters/abstract/
connection_specification.rb:98)
DEPRECATION WARNING: ActiveRecord::Base.verification_timeout= has been deprecated
and no longer has any effect. Please remove all references to
verification_timeout=.. (called from verification_timeout= at
D:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
connection_adapters/abstract/connection_specification.rb:108)
rake aborted!
no such file to load -- hpricot
I've installed hpricot gem also (version 0.8).
What is the remedy for this?
Install the rcov gem:
gem install relevance-rcov --source http://gems.github.com
The most significand error is
rake aborted!
no such file to load -- hpricot
You need hpricot. You can install it running the following command on the command line
gem install hpricot
Maybe your system can't find the gems. This could be a path problem, see this post for details.

Resources