Rails crashes my fcgid/fastcgi/scgi on apache2/lighttpd :<

Or maybe I crash it and don’t know why. Here is the setup:

I have an action that will crash my debian sarge development box
using fcgid, fastcgi and scgi running with Apache2, as well as
fastcgi running with lighttpd, every time. Here is the action from
the controller:


def crashme
@orders = Order.find(:all, :order => "id ASC", :offset =>
0, :limit => 200)
emails_array = Array.new
@orders.each{ |order|
a_email = OrderMailer.create_a(order, price, pre_tax_price,
sales_tax)
emails_array << a_email
if order.confirmed_email?
verification_email = OrderMailer.create_a_verification
(order, pre_tax_price, sales_tax)
emails_array << verification_email
end
}
flash[:notice] = 'Array Size: ’ + emails_array.size.to_s
emails_array.each{ |email|
email.set_content_type(“text/html”)
OrderMailer.deliver(email)
}
redirect_to :action => “list”
end

It doesn’t even start sending mails - it crashes somewhere in the
arrays when doing ‘.each’. The order model is ~40 fields, mostly
ints and dates, but some varchar. If I cut the limit down to ~50, it
will run ok.

When it “crashes”, I get a line in my apache server log for my rails
virtualhost like this:

[Wed Jul 19 11:30:01 2006] [error] [client 204.11.129.35] Premature
end of script headers: dispatch.fcgi

And no other logs (grrr).

I also get this output on my ssh session sometimes when I run the
action and make it crash:

(eval):1: [BUG] Segmentation fault ruby 1.8.2 (2005-04-11) [x86_64-
linux]

Can anyone share any insight? Am I running out of memory or
something? How could I tell? Or is there a bug in my ruby like the
console output tells me?

Thanks in advance,

Nicholas P. Mueller

Further information:

When I run my app in script/console and start entering the code from
the action, after I close the each, it throws this error:

/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/
core_ext/class/inheritable_attributes.rb:100: [BUG] Segmentation fault
ruby 1.8.2 (2005-04-11) [x86_64-linux]

Is it a memory thing or a bug in Ruby on Debian Sarge?

Nicholas P. Mueller

@orders.each{ |order|
a_email = OrderMailer.create_a(order, price, pre_tax_price, sales_tax)
emails_array << a_email
if order.confirmed_email?

Don’t you need a “then” at the end of the above line?

Nicholas P. Mueller wrote:

/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/
core_ext/class/inheritable_attributes.rb:100: [BUG] Segmentation fault
ruby 1.8.2 (2005-04-11) [x86_64-linux]

Is it a memory thing or a bug in Ruby on Debian Sarge?

As I remember people had a lot of problems with running Rails on Ruby
1.8.2. In all cases switching to 1.8.4 helped. You could try to verify
that on development box.

Cheers,
Łukasz Piestrzeniewicz

You don’t need a “then” if you lay out your “if” statement on
multiple lines.

From the pickaxe (http://whytheluckystiff.net/ruby/pickaxe/)
“expressions” section:


An if expression in Ruby is pretty similar to ``if’’ statements in
other languages.

if aSong.artist == “Gillespie” then
handle = “Dizzy”
elsif aSong.artist == “Parker” then
handle = “Bird”
else
handle = “unknown”
end

If you lay out your if statements on multiple lines, you can leave
off the then keyword.

if aSong.artist == “Gillespie”
handle = “Dizzy”
elsif aSong.artist == “Parker”
handle = “Bird”
else
handle = “unknown”
end

However, if you lay your code out more tightly, the then keyword is
necessary to separate the boolean expression from the following
statements.

if aSong.artist == “Gillespie” then handle = “Dizzy”
elsif aSong.artist == “Parker” then handle = “Bird”
else handle = “unknown”
end

You can have zero or more elsif clauses and an optional else clause.

I really think it is either a ruby bug in the debian package or a
memory thing.

Nicholas P. Mueller