Why Is Ruby Throwing a Segmentation Fault on Only My System, and Only in This Rails Application

Why is Ruby throwing a Segmentation fault on only my system, and only in this Rails application?

Ok, I've fixed this on my machine. I'm not sure exactly why, but downgrading the ruby-debug gem to version 0.10.0 solves the problem for me.

The specific fix is running the following commands:

sudo gem uninstall ruby-debug

sudo gem install ruby-debug --version 0.10.0

Segmentation fault with Rails 5 app with Mongoid

Solved. This is a bug affecting Ruby 2.4:


Rails Script Segmentation Fault with RVM

There's a problem with you RVM installation. which should return


Upgrade to the latest RVM installation. There was a bug in the 1.0 release with "shell path caching".

$ rvm get head
$ rvm reload
$ rvm repair all
$ rvm use 1.9.2

Segfault when calling OpenProcessToken via Ruby/DL

This bug is not due to ruby but to your code.

You used the inappropriate method ref on a variable of DL::CPtr type in the open_process_token method.

The method open_process_token

def self.open_process_token
token_handle = DL::CPtr.malloc(DL::SIZEOF_VOIDP, DL::RUBY_FREE)
OpenProcessToken(Win.GetCurrentProcess, 0x8, token_handle.ref)

Should be

def self.open_process_token
ptoken_handle = DL::CPtr.malloc(DL::SIZEOF_VOIDP, DL::RUBY_FREE)
OpenProcessToken(Win.GetCurrentProcess, 0x8, ptoken_handle)
token_handle = ptoken_handle.ptr.to_i

(Thanks to Heesob Park on this non-issue.)

Creating Ruby time object causing garbage collection problem

Sounds like an interesting project.

You only need one Time object per interval, since you can do arithmetic operations with times. For example:

t0 = Time.new

while(1) do

if ( Time.new - t0 >= 60 ) # test using one minute
# poll inverters, update database
t0 = Time.new


Then you don't need to worry about GC issues.

PS. +1 for using delayed_job or some other way of putting this in its own thread, or cron if you can run it as its own process, since a loop like this or using sleep() will block everything else.

Related Topics

Leave a reply