Segmentation fault (core dumped) in rails 6 - ruby-on-rails

I've installed Ubuntu 22.04 recently.
Now I have to setup a rails 6 project with ruby 2.6.6.
The setup is complete,Now when I start server and navigate to localhost:3000, It shuts down with the below main errors.
I've never caught such errors so I'm a bit confused.
Can anyone here help me?
`Started GET "/" for ::1 at 2023-02-04 16:29:10 +0500
/home/ruby-dev/.rvm/gems/ruby-2.6.6#beambox/gems/listen-3.2.1/lib/listen/record/entry.rb:53: [BUG] Segmentation fault at 0x00007f9602f18140
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0013 p:---- s:0062 e:000061 CFUNC :open
c:0012 p:---- s:0059 e:000058 CFUNC :join
c:0011 p:0026 s:0054 E:001f28 METHOD /home/ruby-dev/.rvm/gems/ruby-2.6.6#beambox/gems/listen-3.2.1/lib/listen/record/entry.rb:53
Segmentation fault (core dumped)`

Consider switching to another version manager like rbenv, which can install the necessary OpenSSL library for your current Ruby version.
Another option should be downgrade the OpenSSL. However, note that downgrading the OpenSSL version may cause other compatibility issues.

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

Segmentation fault on ruby installed with rbenv

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.

Segmentation fault using ActionMailer with Ruby 1.9.3-p125

I was happily sending email from my web app using ActionMailer, using ruby 1.9.2-p180. Then I upgraded to ruby 1.9.3-p125, using RVM.
Now I am getting a segmentation fault every time I try to send and email.
/Users/disaacs/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/net/smtp.rb:583: [BUG] Segmentation fault
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]
-- Control frame information -----------------------------------------------
c:0092 p:---- s:0499 b:0499 l:000498 d:000498 CFUNC :connect
c:0091 p:0059 s:0496 b:0496 l:000495 d:000495 METHOD /Users/disaacs/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/net/smtp.rb:583
c:0090 p:0255 s:0491 b:0490 l:001180 d:001180 METHOD /Users/disaacs/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/net/smtp.rb:560
c:0089 p:0047 s:0482 b:0482 l:000481 d:000481 METHOD /Users/disaacs/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/net/smtp.rb:519
c:0088 p:0496 s:0475 b:0475 l:000474 d:000474 METHOD /Users/disaacs/.rvm/gems/ruby-1.9.3-p125/gems/mail-2.3.0/lib/mail/network/delivery_methods/smtp.rb:128
c:0087 p:0031 s:0464 b:0464 l:000463 d:000463 METHOD /Users/disaacs/.rvm/gems/ruby-1.9.3-p125/gems/mail-2.3.0/lib/mail/message.rb:1989
c:0086 p:0009 s:0460 b:0460 l:000436 d:000459 BLOCK /Users/disaacs/.rvm/gems/ruby-1.9.3-p125/gems/mail-2.3.0/lib/mail/message.rb:230
c:0085 p:0021 s:0458 b:0458 l:000440 d:000457 BLOCK /Users/disaacs/.rvm/gems/ruby-1.9.3-p125/gems/actionmailer-3.1.1/lib/action_mailer/base.rb:432
I've seen some similar questions, but nothing with definitive answers. Is this a well know issue with no answer?
I am running Rails 3.1.1 on OSX 10.6.8.
I ran into a similar issue with Paperclip that was related to how openssl was compiled when installing ruby 1.9.3. Not 100% sure this is the same issue your having, but I'd bet it is.
To solve this issue I reinstalled ruby and fresh gemset after installing the rvm openssl pkg:
$ rvm pkg install openssl
$ rvm remove 1.9.3-p125
$ rvm install 1.9.3-p125 --with-openssl-dir=$rvm_path/usr

Rails 3.1 and Ruby 1.9.3p125: ruby-debug19 still crashes with "Symbol not found: _ruby_threadptr_data_type" [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
ruby-debug with Ruby 1.9.3?
I had heard rumors that ruby 1.9.3p125 has a solution for the ruby-debug19 problem, so per instructions on the RVM site, I reinstalled 1.9.3:
$ rvm reinstall 1.9.3 --patch debug --force-autoconf
$ ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.2.0]
Then:
gem install ruby-debug19
Added this entry to my Gemfile:
gem 'ruby-debug19'
Then:
$ rails server -u
=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
Exiting
To get past this error I changed my Gemfile entry to:
gem 'ruby-debug19', :require => 'ruby-debug'
Now a new error from the server:
/Users/don/.rvm/gems/ruby-1.9.3-p125/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require': dlopen(/Users/don/.rvm/gems/ruby-1.9.3-p125/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle, 9): Symbol not found: _ruby_threadptr_data_type (LoadError)
Referenced from: /Users/don/.rvm/gems/ruby-1.9.3-p125/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
Expected in: flat namespace
in /Users/don/.rvm/gems/ruby-1.9.3-p125/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle - /Users/don/.rvm/gems/ruby-1.9.3-p125/gems/ruby-debug-base19-0.11.25/lib/ruby_debug.bundle
I'm very confused by the hundreds of posts out there on how to handle this ruby-debug19 issue. I was hoping it had been solved. Apparently not. Any suggestions? (If anyone suggests a patch, please provide step by step instructions on how to apply it. I've struggled with patches in the past.)
A fork of ruby-debug just called 'debugger' now exists that incorporates many of the fixes people had been deploying on top of ruby-debug19, so you should be able to just change your Gemfile to
gem 'debugger'
... and off you go.
Long story short: it's not resolved, and official resolution will only come with a new version of ruby-debug19 or ruby-debug-base19. It's pretty aggravating, I know.
I've done a lot of digging on this, too, and I've kept an eye on things since 1.9.3 came out (because we'd love-love-love to use it in production). However, sadly, 1.9.3-p125 doesn't have a fix for ruby-debug. Only ruby-debug19 will have the fix for ruby-debug19, as the authors of ruby-debug19 and ruby-debug-base19 have been working on a patch and have an updated test build working on Ruby 1.9.3… but they haven't released it to the general public. ruby-debug-base19 hasn't seen a release in eons; ruby-debug19 even longer (since '09).
If you're on rvm head, you should be able to install 1.9.3-p125 with the added "falcon patch" found here (and noted about RVM here. This gist seems to have better instructions (it's a newer fork of the older one).
The best thing to do is just use pry. Its an irb-like replacement for ruby-debug and it works with all version of Ruby with no nasty patching!
https://github.com/pry/pry
You must pass the --with-ruby-include and point it at your src directory for this to work.
(most of these answers elsewhere on SO have gone stale since 1.9.3-p125.)
I've written up new instructions here for ubuntu 11.10 that work on my machine, but give them a try on darwin and see if they help?: https://gist.github.com/2218661
I've been having similar problems using Rails 3.2 with Ruby 1.9.3p0 debugging in Aptana.
For me, new ruby-debug-base193 does not compile. But what works fine is a fix that has been posted elsewhere:
Gemfile:
gem 'ruby-debug-ide19'
gem 'ruby-debug-base19'
And then providing the missing is_binary_data? method somewhere. I put it in my Rails application.rb file like so:
class String
def is_binary_data?
( self.count( "^ -~", "^\r\n" ).fdiv(self.size) > 0.3 || self.index( "\x00" ) ) unless empty?
end
end

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!

Resources