rails: SystemStackError stack level too deep - actionpack (4.0.0.beta1) lib/action_dispatch/middleware/reloader.rb:70

I upgraded to Rails 4.0beta1 and Ruby 2.0 and now every time I try to open my rails app from a new browser session (every time I clear my cookies), I get:

SystemStackError in AnythingController#Index
stack level too deep

The controller can be anything, it happens on all pages. The full traceback is just:

actionpack (4.0.0.beta1) lib/action_dispatch/middleware/reloader.rb:70

Simply refreshing the page makes it load and the full traceback is just that 1 single line.

Any ideas what it could be and how to troubleshoot?

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 20 (7 by maintainers)

Most upvoted comments

Just a note for any future generations.

If you get a SystemStackError with a single backtrace line: actionpack (X.X.X) lib/action_dispatch/middleware/reloader.rb:70 then in 99.99% of cases this is a bug in your application code and not a Rails bug. What happens is that since Ruby version 1.9 a backtrace generated by SystemStackError is completely useless (always consisting of a single line, this is a bug in Ruby, see https://bugs.ruby-lang.org/issues/6216 /cc @matz @ko1). Therefore whenever your app’s code blows the stack, you never get the relevant backtrace pointing back to your code, but instead you get a completely misleading and irrelevant backtrace pointing at Rails (like reported above).

How can you debug this? Try running your app with Ruby 1.8, Rubinius or JRuby (all these will provide you with usable backtraces), alternatively you can go @inspire22’s way (I also did this in my app) and manually edit Rails’ code iteratively removing relevant rescue statements until the backtrace starts pointing at your code.