Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SystemStackError triggered by changing files while server is running?

On my RoR app development machine (local server, OSX 10.8.1, Ruby 1.9.3, Rails 3.2.8) something odd started to appear out of thin air (of course…):

The Rails server collapses (all routes are killed, server restart is the only way to get it working again) with the following log entries:

SystemStackError (stack level too deep):
  actionpack (3.2.8) lib/action_dispatch/middleware/reloader.rb:70


  Rendered /Users/dekay/.rvm/gems/ruby-1.9.3-head@global/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.9ms)
  Rendered /Users/dekay/.rvm/gems/ruby-1.9.3-head@global/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.2ms)
  Rendered /Users/dekay/.rvm/gems/ruby-1.9.3-head@global/gems/actionpack-3.2.8/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (14.7ms)

I have googled and found that the SystemStackError is usually due to an endless loop, but as far as I can trace it I have no such loop in my code. And the error does not seem to be in a certain step of application logic.

The only correlation between server crash and my actions is as follows:

  1. Change some code in the app
  2. Reload the current web page of the app
  3. Boom, server gone, error message.
  4. No pages work after this, error is:

    Routing Error

    No route matches [GET] "/"

    Try running rake routes for more information on available routes.

Can anyone point me in the right direction to debug this, please? PS: I suspect it happened after a careless "bundle update". Can this be?

like image 226
danieldekay Avatar asked Dec 03 '12 21:12

danieldekay


1 Answers

Debugging a stack level too deep error message in a rails app isn't easy, since the error could be because of a variety of reasons, and the error message isn't too helpful.

Some of the reasons leading to a stack level too deep error:

  1. Inconsistency in the gems & plugins and any other dependencies of the application.
  2. Code syntax error
  3. Inconsistency caused by applying db migrations erroneously.

If the error was happening on system boot up, then this tip would be very useful: http://www.datatravels.com/technotes/2012/07/11/awesome-debugging-for-rails-boot-stacklevel-too-de/

From the description, it looks like the app works fine for a while, and then starts crashing - so the above boot up case might not apply.

One way to go about figuring out the problem would to isolate the specific line/block of code that's causing the error by using printf debugging

Also, it might be worthwhile rolling back the changes and getting the system back to working state, and then put back the changes incrementally to isolate the root cause.

It is quite likely the bundle update did trigger the error in this case; so would be a good idea to check the newly added dependencies and see if they could be the culprit.

like image 120
Prakash Murthy Avatar answered Oct 21 '22 12:10

Prakash Murthy