Running Rails on 64-Bit Linux - Segmentation Fault

Just wanted to post a warning for everyone out there.

We just migrated our application to a 64-Bit Red Hat Enterprise 5
Server, and when we migrated we dutifully installed the latest ruby
patch p230 for Ruby 1.8.6. As soon as we got our web server running
(Litespeed), our pages failed for what seemed like no reason.

At first, my only inkling on the rails side was a failure on the
“protect_from_forgery?” function on a remote form, but then I started
getting 503 errors, which shouldn’t happen. Worse yet, it happened
intermittently, so repeating the problem was almost impossible.

When I dug into the server’s error log, I started seeing a
segmentation fault [bug] warning. It’s not something we’ve ever
experienced with our site or with Ruby.

Low and behold, after much hand wringing and searching the depths of
every ruby, rails, and linux groups, it turns out that ruby-1.8.6-p230
causes the segmentation fault sometimes when the ActiveSupport gem is
called. To fix the problem, we downgraded our Ruby version to what we
originally developed on ruby-1.8.6-p111. All is well. no more wierd
errors or segmentation faults.

I know we searched far and wide for an answer to this issue, so I
thought it would be a good idea to post how we fixed it.

On another note: when installing ruby and rails on the Red Hat
Enterprise 5, make sure you have the zLib-devel and openssl-devel
installed before you install ruby, or your ruby installation and
subsequent rails installation can get almost hopelessly borked.
Sometimes zLib and openssl is there, but zLib-devel and openssl-devel
may not be. Use Yum to install them…it’s just easier. the ROR wiki
says to use ‘up2date zlib_devel’, but up2date is not valid on Red Hat
Enterprise 5.

That’s it. I hope we saved someone a few hours.
-Chris

On Thu, 2008-07-31 at 14:10 -0700, Christopher Hazlett wrote:

intermittently, so repeating the problem was almost impossible.
errors or segmentation faults.
says to use ‘up2date zlib_devel’, but up2date is not valid on Red Hat
Enterprise 5.

That’s it. I hope we saved someone a few hours.


I’m sort of curious…

rpm -q ruby

ruby-1.8.5-5.el5_2.3

Where did you get ruby-1.8.6-XXX from?

That’s not part of normal RedHat packages as far as I can tell.

yes, the original -p230 (patch 230) packages were a problem but that
problem affected everyone, everywhere and not just Red Hat or Fedora
users. That was a ruby problem and they came out with a second and third
round of patches which seemed to fix things.

FWIW, I have no problem with Fedora’s ruby-1.8.6.230-4 packages w/
rails…

rpm -qa|grep ruby

ruby-libs-1.8.6.230-4.fc9.i386
ruby-rdoc-1.8.6.230-4.fc9.i386
ruby-1.8.6.230-4.fc9.i386
ruby-irb-1.8.6.230-4.fc9.i386
ruby-ri-1.8.6.230-4.fc9.i386
ruby-devel-1.8.6.230-4.fc9.i386
ruby-mode-1.8.6.230-4.fc9.i386
ruby-ldap-0.9.7-5.fc9.i386

Craig

I didn’t use the rpm or yum packages because they stopped at
1.8.5.el5_2.3, at least the packages I could find.
So I compiled from source after wget
ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.6-p111.tar.gz
and then you followed the steps at
http://www.redhatmagazine.com/2006/11/16/ruby-on-rails-on-red-hat/.

It’s actually good to know that the 230-4 patch works as expected. I
couldn’t find that written up anywhere…that would have saved me some
time. Plus, I was trying to get a 64 bit build, which you will get
when you compile from source. Installing with the rpm package only
gives you i386. Now, I don’t know everything, obviously, We’ve only
just graduated to our shiny new 64-bit server and had been working on
a 32-bit during all of our dev work. Take it with a grain of salt.

-Chris

On Thu, 2008-07-31 at 15:47 -0700, Christopher Hazlett wrote:

just graduated to our shiny new 64-bit server and had been working on
a 32-bit during all of our dev work. Take it with a grain of salt.


That article is over 2 years old…a lifetime in ruby on rails and too
much salt gives you high blood pressure.

ummm…the reason that you use a package management system is to manage
installed software and when you need to compile from source, you really
don’t want to just do the make && make test && make install sort of
thing but rather build rpm’s. If you need to update/remove, it’s a mess
to start fooling in /usr/local/…

I’m not sure why you needed ruby 1.8.6 instead of the 1.8.5 that is
standard RHEL packages but it’s simple enough to build 1.8.6 rpm’s which
replace the RHEL packages, and could easily be uninstalled or updated
without fuss…

AND

the packages you build will be x86_64 if your platform is x86_64

These are the steps I used to compile (though I didn’t bother
installing) and to install up to date ruby packages on a Red Hat type
system (note - the ‘spec’ file knows which ‘devel libraries’ are needed
and you can see, I needed to install some to build ruby packages)…

cd /opt
wget
http://mirrors.usc.edu/pub/linux/distributions/fedora/linux/updates/9/SRPMS/ruby-1.8.6.230-4.fc9.src.rpm
rpm -ivh ruby-1.8.6.230-4.fc9.src.rpm
cd /usr/src/redhat/SPECS/
rpmbuild -bb ruby.spec
cd /usr/src/redhat/RPMS/i386
rpm -Uvh
ruby-1.8.6.230-4.i386.rpm
ruby-devel-1.8.6.230-4.i386.rpm
ruby-docs-1.8.6.230-4.i386.rpm
ruby-irb-1.8.6.230-4.i386.rpm
ruby-libs-1.8.6.230-4.i386.rpm
ruby-mode-1.8.6.230-4.i386.rpm
ruby-rdoc-1.8.6.230-4.i386.rpm
ruby-ri-1.8.6.230-4.i386.rpm
ruby-tcltk-1.8.6.230-4.i386.rpm

Notes:

  • I used the latest ruby-1.8.6.230-4 Source RPM from Fedora (9)
  • I had to install readline-devel gdbm-devel tcl-devel tk-devel byacc
    and as you noted, it’s likely that one would need zlib-devel and
    openssl-devel if not other packages too.
  • If your platform is x86_64, then your RPMS’s would be in that folder
  • you don’t have to install all the packages (I don’t use ruby-tcltk)
  • Fedora 9 has a number of other ruby packages that may be of
    interest…

http://mirrors.usc.edu/pub/linux/distributions/fedora/linux/updates/9/SRPMS/

Craig

On Fri, 2008-08-01 at 09:24 -0700, Christopher Hazlett wrote:

From the coddled world of IIS and .NET to getting our Linux running
Ruby has been painful at times…and I really appreciate the advice
and clarification.

Thankfully, other than not using RPM, things are running smoothly
now. I’ll have to rectify the RPM issue for maintenance’s sake.

Thanks again,


as an FYI

Craig

Thanks Craig. These are all good things to know.

I knew the articles were a couple of years old. I guess this is one of
the issues you run into when working with open source, there is so
much information of so varying quality, that you really need to pick
your resources carefully. Sometimes articles are new and wrong…and
sometimes they are old and right. It sucks when you’re really just
getting into the Linux world because the sheer quantity of information
is daunting.

From the coddled world of IIS and .NET to getting our Linux running
Ruby has been painful at times…and I really appreciate the advice
and clarification.

Thankfully, other than not using RPM, things are running smoothly
now. I’ll have to rectify the RPM issue for maintenance’s sake.

Thanks again,
-Chris

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs