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

**URL:** <https://www.ruby-forum.com/t/rails-crashes-my-fcgid-fastcgi-scgi-on-apache2-lighttpd/99048>\
**Category:** Rails\
**Created:** [July 20, 2006, 12:36am UTC](https://www.ruby-forum.com/t/rails-crashes-my-fcgid-fastcgi-scgi-on-apache2-lighttpd/99048 "2006-07-20T00:36:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicholas\_PSMueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@Nicholas\_PSMueller](https://www.ruby-forum.com/u/Nicholas_PSMueller)\
**Post date:** [July 20, 2006, 12:36am UTC](https://www.ruby-forum.com/t/rails-crashes-my-fcgid-fastcgi-scgi-on-apache2-lighttpd/99048/1 "2006-07-20T00:36:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nicholas\_PSMueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@Nicholas\_PSMueller](https://www.ruby-forum.com/u/Nicholas_PSMueller)\
**Post date:** [July 20, 2006, 12:39am UTC](https://www.ruby-forum.com/t/rails-crashes-my-fcgid-fastcgi-scgi-on-apache2-lighttpd/99048/2 "2006-07-20T00:39:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nicholas\_PSMueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@Nicholas\_PSMueller](https://www.ruby-forum.com/u/Nicholas_PSMueller)\
**Post date:** [July 20, 2006, 12:52am UTC](https://www.ruby-forum.com/t/rails-crashes-my-fcgid-fastcgi-scgi-on-apache2-lighttpd/99048/3 "2006-07-20T00:52:48Z")

</div>

> @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?

---

<div class="post-metadata">

**Author:** ![Nicholas\_PSMueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@Nicholas\_PSMueller](https://www.ruby-forum.com/u/Nicholas_PSMueller)\
**Post date:** [July 20, 2006, 7:35am UTC](https://www.ruby-forum.com/t/rails-crashes-my-fcgid-fastcgi-scgi-on-apache2-lighttpd/99048/4 "2006-07-20T07:35:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nicholas\_PSMueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ad7895/32.png) [@Nicholas\_PSMueller](https://www.ruby-forum.com/u/Nicholas_PSMueller)\
**Post date:** [July 20, 2006, 9:16pm UTC](https://www.ruby-forum.com/t/rails-crashes-my-fcgid-fastcgi-scgi-on-apache2-lighttpd/99048/5 "2006-07-20T21:16:19Z")

</div>

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

From the pickaxe ([http://whytheluckystiff.net/ruby/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
