Segfault after page view

I realize this is slightly off-topic, but I’m stumped and I hope someone
else has had the same problem.

When running a rails app using webrick (script/server), I can load any
given page which involves a controller once, and any subsequent page
loads trigger a “Segmentation fault” without any other info.

This problem is very new, and has only started occurring since I last
updated my Gentoo linux system, so I assume it’s something to do with
Gentoo, but the only place I see a problem is with rails. In fact, it’s
only with my personal projects; instiki works just fine (as do basic,
html-loading webrick instances).

Go ahead and ask me any questions you think might be useful. I have all
kinds of details. I wouldn’t ask this here if I had somewhere else to

Thank you.


Try running memtest86. The first thing I think when I start seeing
segfaults is bad RAM.

If that doesn’t show anything, I’d try recompiling ruby and reinstalling
rails freshly.


Memory appears to be ok… I did try recompiling ruby (1.8.4-r1) and
reinstalling the rails gem (as well as activerecord, actionpack,
actionmailer, actionwebservice, activesupport). No effect.

What’s odd is that everything works fine on the first page request, so
if I keep stopping and restarting webrick, then I can use the
application. If anyone’s interested in an strace, I have that too. Any
other ideas?


As an interesting side note, it’s not just webrick, mongrel also
segfaults in precisely the same way. The bizarreness of this problem is


On Feb 21, 2006, at 1:33 PM, Payton S. wrote:

When running a rails app using webrick (script/server), I can load
somewhere else to turn.
Thank you.

I have a similar problem that only seems to effect Hieraki but not
any of the rails apps that I am writing. During a callback from
doing an insert into the user table, the ruby interpreter seg-
faults. It is in the middle of the Activerecord base class. It is
trying to invoke create_or_update (if I remember correctly) and it
appears to try to start executing code in the middle of the method,
not the beginning. At this point, it is in ruby code but it has been
calling into the C routines that interface into MySQL. I am running
Ruby 1.8.4, Rails 1.0.0, MySQL 4.1.18, and the MySQL 2.7 ruby
interface routines. All this is running on FreeBSD 5.4. I have tried
compiling everything from scratch. I have tried running Hieraki as a
cgi, fast-cgi and scgi process using Apache 2.0.55. I have also
tried running it using Webrick. I have tried running it on another
machine, using the same OS and software versions. I have also tried
running it with PostgreSQL 8.1.2 using the C interface version
0.7.1. It always seems to seg-fault in the same place.

I haven’t had any more time to pursue the problem in the last few
weeks and unfortunately, I won’t have time to look into it any
further for a few weeks.


Kim S. - principal, Shrier and Deihl - mailto:[email protected]
Remote Unix Network Admin, Security, Internet Software Development
Tinker Internet Services - Superior FreeBSD-based Web Hosting

The gentoo install is 2005.1 and I installed it about 4 months ago.
There have never been any problems with ruby until this last emerge.
The architecture is ~x86 and I doubt there’s anything wrong with my
make.conf settings, as those haven’t changed.

At the bottom of this message is a list of all the packages I emerged
when this became a problem. I use ruby and rubygems from portage, but I
use rails and associated packages from gems. I’m using ruby-1.8.4-r1
and rubygems-0.8.11. Neither are masked. (I have also tried

I was loading ruby-mysql, but I have since disabled activerecord, and
there been no change in the problem.

I have searched the Gentoo bugzilla for a ruby or rails problem like
mine, but have not found any help. I’m submitting my problem there too
in hopes of an answer.

Packages emerged:


Crap. I was hoping that my questions would shake loose a solution from
another quarter…
I’m kind of out of ideas. I don’t see anything in that emerge list that
would cause
problems with ruby… although, I’m no expert on linux library

What seems really weird about this is that third party rails apps still
work fine but your
code breaks. Are you doing anything “crazy” in your code? I have no idea
what “crazy”
might look like, but I guess anything that’s not like typical rails

You could also try to narrow down where the segfault is occuring with
breakpoints or log
statements. Maybe some piece of Ruby was installed outside of portage at
some point and is
still around, and somehow your code is going off into that old code…
where things aren’t
arranged in memory quite the way they should be.

As you can probably guess I’m kind of whiffing in the breeze here… I
don’t have any
solid ideas, just trying to give you some avenues of exploration.

Oh, and someone else was talking about suspecting memory when they get
segfaults, but I’ve
never thought that. Having done a little beginning programming in C, I’m
all too familiar
with how easy it is to segfault: just mess up where your pointers are
pointing and your
there! (Did that over and over and over… :slight_smile: )

good luck!


How long have you been running this gentoo install? Is it fairly new?

Are you sure your CFLAGS and MARCH or MCPU are set correctly in
make.conf? What arch are
you running?

Did you update GCC recently? If so, was it the 3.3.* to 3.4.* jump, cuz
that required an
upgrade to libtool and the installation of a libstdc++ compat library?

Did you use the rails/ruby packages from portage? Did you use masked

Did you check gentoo’s bugzilla for any reports of segfaults in

What exactly was that last update you did? Rails/Ruby weren’t part of
that upgrade right?


I struggled with segfaults for about a month. The only thing that fixed
mine was:

gem uninstall mysql

I then dowloaded the latest ruby mysql bindings off the web and used
those. If you already disabled active record this probably won’t help
but thought I would mention it anyways.


On Wed, 2006-02-22 at 09:45 -0800, Ben M. wrote:

still around, and somehow your code is going off into that old code… where things aren’t
good luck!

when this became a problem. I use ruby and rubygems from portage, but I


Did you update GCC recently? If so, was it the 3.3.* to 3.4.* jump,
that upgrade right?

any given page which involves a controller once, and any subsequent
else to turn.

[email protected]

Charlie B.
Castle Branch Inc.

I’ve actually encountered some of this on Windows recently, under
WEBrick and Mongrel.
I’m still trying to isolate a test case, sadly.

Here’s an example of what I’m seeing:
[BUG] Segmentation fault
ruby 1.8.4 (2005-12-24) [i386-mswin32]

This application has requested the Runtime to terminate it in an unusual
Please contact the application’s support team for more information.

I don’t have MySQL installed; I only use Postgres and Oracle.