Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR SystemStackError: stack level too deep in active_support_encoder.rb:17 #112

Closed
emaillenin opened this issue Dec 1, 2014 · 10 comments

Comments

@emaillenin
Copy link

When I add,

gem 'rack-mini-profiler', require: false

in my Gemfile and

if Rails.env == 'development'
  require 'rack-mini-profiler'

  # initialization is skipped so trigger it
  Rack::MiniProfilerRails.initialize!(Rails.application)
end

in my initializer, I get the following trace at the end of my Rails log for all requests and I do not see the Mini Profiler. App works fine though.

[2014-12-01 20:28:23] ERROR SystemStackError: stack level too deep
    /Users/leninraj/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/set.rb:81
[2014-12-01 20:28:23] ERROR SystemStackError: stack level too deep
    /Users/leninraj/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/set.rb:81
[2014-12-01 20:28:23] ERROR SystemStackError: stack level too deep
    /Users/leninraj/.rvm/gems/ruby-2.1.2/bundler/gems/activesupport-json_encoder-072ab26faeaa/lib/active_support/json/encoding/active_support_encoder.rb:17

When I remove the gem and the initializer, I do not see this error in the trace. This is the code around active_support_encoder.rb:17

def initialize(options = nil)
  @options = options || {}
  @seen = Set.new
end

Here is my Gemfile:

source 'https://rubygems.org'

ruby '2.1.2'

gem 'rails', '4.1.4'
gem 'pg'
gem 'haml'
gem 'haml-rails', '~> 0.5.3'
gem 'paperclip', '4.2.0'
gem 'font-awesome-rails'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jquery-turbolinks'
gem 'jquery-ui-rails'
gem 'jbuilder', '~> 1.2'
gem 'devise'
gem 'simple_form'
gem 'merit', '~> 2.0'
gem 'icalendar'
gem 'kaminari'
gem 'rails-api'
gem 'piwik_analytics', '~> 1.0'
gem 'redis', '~> 3.0'
gem 'whenever'
gem 'omniauth'
gem 'slim-rails'
gem 'meta-tags'
gem 'tinymce-rails'
gem 'select2-rails'
gem 'js-routes'
gem 'pundit'
gem 'parsley-rails'
gem 'parsley_simple_form'
gem 'httpclient'
gem 'psych', '2.0.5'
gem 'twitter'
gem 'backbone-on-rails'
gem 'require_all'
gem 'activeadmin', github: 'activeadmin'
gem 'active_model_serializers', '~> 0.9.0'
gem 'activesupport-json_encoder', github: 'chancancode/activesupport-json_encoder'
gem 'sitemap_generator'
gem 'sass'
gem 'compass-rails' # should be in general group, not in assets
gem 'httparty'
gem 'capistrano'
gem 'capistrano-safe-deploy-to'
gem 'capistrano-unicorn-nginx'
# gem 'rack-mini-profiler', require: false
gem 'oj'
gem 'oj_mimic_json'

group :doc do
  gem 'sdoc', require: false
end

group :development do
  gem 'bullet'
  gem 'better_errors'
  gem 'binding_of_caller'
  gem 'rspec-rails'
  gem 'meta_request'
end

group :test do
  gem 'database_cleaner'
  gem 'capybara', '~> 2.2.0'
  gem 'selenium-webdriver'
  gem 'cucumber-rails', require: false
  gem 'capybara-select2'
  gem 'pickle'
  gem 'timecop'
  gem 'capypage', :path => 'vendor/gems/capypage-0.2.6'
end

group :development, :test do
  gem 'factory_girl_rails', '~> 4.0'
  gem 'pry'
end

group :assets do
  gem 'coffee-rails', '~> 4.0.0'
  gem 'uglifier', '>= 1.3.0'
end

What could be the issue? How do I get mini profiler to work?

@SamSaffron
Copy link
Member

Can I see the full backtrace?

@emaillenin
Copy link
Author

Sadly this is the only trace that is printed in the log. Here is the complete log of a single request after enabling rack-mini-profiler gem and its initializer:

As mentioned earlier, the lat few lines does not appear if I remove the rack-mini-profiler gem and its initializer code. I am not really sure why the trace is incomplete. Also the trace does not have any files related to your gem.

  duggout (master) rails server -p 3113                                                                                                                                                                     
=> Booting WEBrick
=> Rails 4.1.4 application starting in development on http://0.0.0.0:3113
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
/Users/leninraj/.rvm/gems/ruby-2.1.2/gems/merit-2.1.2/lib/merit.rb:83: warning: already initialized constant Merit::AppBadgeRules
/Users/leninraj/.rvm/gems/ruby-2.1.2/gems/merit-2.1.2/lib/merit.rb:83: warning: previous definition of AppBadgeRules was here
/Users/leninraj/.rvm/gems/ruby-2.1.2/gems/merit-2.1.2/lib/merit.rb:84: warning: already initialized constant Merit::AppPointRules
/Users/leninraj/.rvm/gems/ruby-2.1.2/gems/merit-2.1.2/lib/merit.rb:84: warning: previous definition of AppPointRules was here
[2014-12-02 18:03:04] INFO  WEBrick 1.3.1
[2014-12-02 18:03:04] INFO  ruby 2.1.2 (2014-05-08) [x86_64-darwin13.0]
[2014-12-02 18:03:04] INFO  WEBrick::HTTPServer#start: pid=66772 port=3113


Started GET "/" for 127.0.0.1 at 2014-12-02 18:03:05 +0530
  ActiveRecord::SchemaMigration Load (0.7ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Processing by IndexController#index as HTML
  Lookup Load (1.5ms)  SELECT  "lookups".* FROM "lookups"  WHERE "lookups"."lkp_type" = 'homepage_items' AND (name_1 = 'image_main')  ORDER BY "lookups"."id" ASC LIMIT 1
  Lookup Load (0.9ms)  SELECT  "lookups".* FROM "lookups"  WHERE "lookups"."lkp_type" = 'homepage_items' AND (name_1 = 'side_1')  ORDER BY "lookups"."id" ASC LIMIT 1
  Lookup Load (0.8ms)  SELECT  "lookups".* FROM "lookups"  WHERE "lookups"."lkp_type" = 'homepage_items' AND (name_1 = 'list_main')  ORDER BY "lookups"."id" ASC LIMIT 1
  Page Load (0.9ms)  SELECT  "pages".* FROM "pages"  WHERE "pages"."url_code" = 'silly-point' LIMIT 1
  Page Load (1.0ms)  SELECT  "pages".* FROM "pages"  WHERE "pages"."url_code" = 'news' LIMIT 1
  Post Load (1.4ms)  SELECT "posts".* FROM "posts"  WHERE "posts"."id" IN (5, 6, 7)
  Category Load (1.3ms)  SELECT "categories".* FROM "categories"  WHERE "categories"."id" IN (15, 1, 10)
  Post Load (0.8ms)  SELECT  "posts".* FROM "posts"  WHERE "posts"."id" = $1 LIMIT 1  [["id", 6]]
  Category Load (1.2ms)  SELECT "categories".* FROM "categories"  WHERE "categories"."id" IN (1)
  Post Load (1.1ms)  SELECT "posts".* FROM "posts"  WHERE "posts"."id" IN (1, 2, 3, 4, 5, 6, 7)
  Category Load (1.2ms)  SELECT "categories".* FROM "categories"  WHERE "categories"."id" IN (17, 1, 10, 15)
  Post Load (1.6ms)  SELECT  "posts".* FROM "posts" INNER JOIN "posties" ON "posts"."id" = "posties"."post_id" WHERE "posties"."target_id" = $1 AND "posties"."target_type" = $2  ORDER BY created_at DESC LIMIT 1  [["target_id", 3], ["target_type", "Page"]]
  Post Load (1.6ms)  SELECT  "posts".* FROM "posts" INNER JOIN "posties" ON "posts"."id" = "posties"."post_id" WHERE "posties"."target_id" = $1 AND "posties"."target_type" = $2  ORDER BY created_at DESC LIMIT 10  [["target_id", 3], ["target_type", "Page"]]
  Category Load (5.7ms)  SELECT  "categories".* FROM "categories"  WHERE "categories"."id" = $1 LIMIT 1  [["id", 1]]
  Category Load (1.9ms)  SELECT  "categories".* FROM "categories"  WHERE "categories"."id" = $1 LIMIT 1  [["id", 10]]
  CACHE (0.0ms)  SELECT  "categories".* FROM "categories"  WHERE "categories"."id" = $1 LIMIT 1  [["id", 1]]
  Post Load (1.1ms)  SELECT  "posts".* FROM "posts" INNER JOIN "posties" ON "posts"."id" = "posties"."post_id" WHERE "posties"."target_id" = $1 AND "posties"."target_type" = $2  ORDER BY created_at DESC LIMIT 1  [["target_id", 2], ["target_type", "Page"]]
  Post Load (0.8ms)  SELECT  "posts".* FROM "posts" INNER JOIN "posties" ON "posts"."id" = "posties"."post_id" WHERE "posties"."target_id" = $1 AND "posties"."target_type" = $2  ORDER BY created_at DESC LIMIT 10  [["target_id", 2], ["target_type", "Page"]]
  Category Load (0.9ms)  SELECT  "categories".* FROM "categories"  WHERE "categories"."id" = $1 LIMIT 1  [["id", 3]]
  Category Load (0.9ms)  SELECT  "categories".* FROM "categories"  WHERE "categories"."id" = $1 LIMIT 1  [["id", 15]]
  Rendered partials/opencricket/_open_cricket_recent.html.erb (1.0ms)
  Rendered index/index.html.erb within layouts/application (345.6ms)
  Rendered partials/opencricket/_search.html.erb (0.8ms)
  Lookup Load (1.5ms)  SELECT  "lookups".* FROM "lookups"  WHERE "lookups"."lkp_type" = 'homepage_items' AND (name_1 = 'series_list')  ORDER BY "lookups"."id" ASC LIMIT 1
  Series Load (1.4ms)  SELECT "series".* FROM "series"  WHERE "series"."id" IN (1, 2, 3, 8, 9, 10)
  Post Load (1.4ms)  SELECT  "posts".* FROM "posts"  WHERE (post_type = 4)  ORDER BY created_at DESC LIMIT 5
  Category Load (1.0ms)  SELECT  "categories".* FROM "categories"  WHERE "categories"."id" = $1 LIMIT 1  [["id", 13]]
  Rendered layouts/_menu.html.erb (35.7ms)
  Rendered layouts/_header.html.erb (43.3ms)
  Rendered layouts/_footer.html.erb (1.1ms)
Completed 200 OK in 1132ms (Views: 1027.8ms | ActiveRecord: 53.9ms)


Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:06 +0530


Started GET "/assets/font-awesome.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:06 +0530


Started GET "/assets/jquery-ui/datepicker.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:06 +0530


Started GET "/assets/jquery-ui/core.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:06 +0530


Started GET "/assets/select2.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:06 +0530


Started GET "/assets/jquery-ui/theme.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:06 +0530


Started GET "/assets/select2-bootstrap.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:06 +0530


Started GET "/assets/parsley.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:06 +0530


Started GET "/assets/nv.d3.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:06 +0530


Started GET "/assets/desktop/960.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:06 +0530


Started GET "/assets/desktop/base.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:06 +0530


Started GET "/assets/desktop/flexslider.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:06 +0530


Started GET "/assets/desktop/fontello.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:06 +0530


Started GET "/assets/desktop/forms.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:06 +0530


Started GET "/assets/desktop/grounds.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/header.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/index.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/matches.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/megamenu.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/mixins.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/players.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/posts.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/scaffold.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/series.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/style.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/superfish.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/teams.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/typeahead-override.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/typeaheadjs.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/ui.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/desktop/variables.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/jquery.turbolinks.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/turbolinks.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/typeahead.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/jquery-ui/core.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/jquery-ui/widget.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/jquery-ui/accordion.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/jquery-ui/tabs.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/jquery-ui/position.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/jquery-ui/tooltip.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/jquery-ui/datepicker.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/tinymce/preinit.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/tinymce-jquery.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/select2.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/js-routes.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/parsley.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/underscore.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/backbone.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/d3.min.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/nv.d3.min.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/duggout.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/templates/commentaries/addCommentary.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/templates/commentaries/index.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/templates/commentaries/item.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/models/commentary.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/collections/commentaries.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/views/commentaries/commentaries_index.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/views/commentaries/commentaries_item.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/views/commentaries/commentaries_new.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:07 +0530


Started GET "/assets/routers/commentaries_router.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/jquery-ui/button.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/jquery-ui/mouse.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/jquery-ui/draggable.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/jquery-ui/resizable.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/jquery-ui/dialog.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/jquery-ui/sortable.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/active_admin/base.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/active_admin/lib/batch_actions.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/active_admin/lib/checkbox-toggler.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/active_admin/lib/dropdown-menu.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/active_admin/lib/flash.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/active_admin/lib/has_many.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/active_admin/lib/modal_dialog.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/active_admin/lib/popover.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/active_admin/lib/table-checkbox-toggler.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/active_admin/ext/jquery-ui.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/active_admin/ext/jquery.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/active_admin/application.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/active_admin.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/carouFredSel.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/customM.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/facebook_sdk.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/flexslider.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/global.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/grounds.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/index.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/jquery.easing.1.3.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/matches.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/mobilemenu.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/mypassion.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/posts.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/series.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/superfish.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/teams.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/__meta_request/ba6f2ffb-eba2-405b-a815-f75213cde14c.json" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/479.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/duggout_helmet_logo.png" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/1000.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/767.css?body=1" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/fontawesome-webfont.woff" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/futura_today_demibold.ttf" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/futura_today_bold.ttf" for 127.0.0.1 at 2014-12-02 18:03:08 +0530


Started GET "/assets/slider-nav.png" for 127.0.0.1 at 2014-12-02 18:03:08 +0530
[2014-12-02 18:03:10] ERROR SystemStackError: stack level too deep
    /Users/leninraj/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/set.rb:81
[2014-12-02 18:03:10] ERROR SystemStackError: stack level too deep
    /Users/leninraj/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/set.rb:81
[2014-12-02 18:03:10] ERROR SystemStackError: stack level too deep
    /Users/leninraj/.rvm/gems/ruby-2.1.2/bundler/gems/activesupport-json_encoder-072ab26faeaa/lib/active_support/json/encoding/active_support_encoder.rb:17

@wesleyer
Copy link

This is what I'm getting.
Not sure if this is the same issue.

SystemStackError - stack level too deep:

11:14:08 web.1       |   rack-mini-profiler (0.9.2) lib/mini_profiler/page_timer_struct.rb:53:in `generate'
11:14:08 web.1       |   rack-mini-profiler (0.9.2) lib/mini_profiler/page_timer_struct.rb:53:in `to_json'
11:14:08 web.1       |   rack-mini-profiler (0.9.2) lib/mini_profiler/profiler.rb:121:in `serve_results'
11:14:08 web.1       |   rack-mini-profiler (0.9.2) lib/mini_profiler/profiler.rb:144:in `serve_html'
11:14:08 web.1       |   rack-mini-profiler (0.9.2) lib/mini_profiler/profiler.rb:201:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   rack (1.5.2) lib/rack/deflater.rb:25:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   versionist (1.3.0) lib/versionist/middleware.rb:39:in `_call'
11:14:08 web.1       |   versionist (1.3.0) lib/versionist/middleware.rb:17:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
11:14:08 web.1       |   warden (1.2.3) lib/warden/manager.rb:34:in `catch'
11:14:08 web.1       |   warden (1.2.3) lib/warden/manager.rb:34:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   rack (1.5.2) lib/rack/etag.rb:23:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   rack (1.5.2) lib/rack/head.rb:11:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   actionpack (4.0.13) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   actionpack (4.0.13) lib/action_dispatch/middleware/flash.rb:241:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) 
lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
11:14:08 web.1       |   rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   actionpack (4.0.13) lib/action_dispatch/middleware/cookies.rb:486:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   activerecord (4.0.13) lib/active_record/query_cache.rb:36:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   activerecord (4.0.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   activerecord (4.0.13) lib/active_record/migration.rb:373:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   actionpack (4.0.13) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
11:14:08 web.1       |   activesupport (4.0.13) lib/active_support/callbacks.rb:373:in `_run__2791909282382737623__call__callbacks'
11:14:08 web.1       |   activesupport (4.0.13) lib/active_support/callbacks.rb:80:in `run_callbacks'
11:14:08 web.1       |   actionpack (4.0.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   actionpack (4.0.13) lib/action_dispatch/middleware/reloader.rb:64:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   actionpack (4.0.13) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
11:14:08 web.1       |   better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
11:14:08 web.1       |   better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   actionpack (4.0.13) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   actionpack (4.0.13) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   railties (4.0.13) lib/rails/rack/logger.rb:38:in `call_app'
11:14:08 web.1       |   railties (4.0.13) lib/rails/rack/logger.rb:20:in `block in call'
11:14:08 web.1       |   activesupport (4.0.13) lib/active_support/tagged_logging.rb:68:in `block in tagged'
11:14:08 web.1       |   activesupport (4.0.13) lib/active_support/tagged_logging.rb:26:in `tagged'
11:14:08 web.1       |   activesupport (4.0.13) lib/active_support/tagged_logging.rb:68:in `tagged'
11:14:08 web.1       |   railties (4.0.13) lib/rails/rack/logger.rb:20:in `call'
11:14:08 web.1       |   quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   actionpack (4.0.13) lib/action_dispatch/middleware/request_id.rb:21:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   rack (1.5.2) lib/rack/runtime.rb:17:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   activesupport (4.0.13) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   rack (1.5.2) lib/rack/lock.rb:17:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   actionpack (4.0.13) lib/action_dispatch/middleware/static.rb:84:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
11:14:08 web.1       |   rack-cache (1.2) lib/rack/cache/context.rb:143:in `pass'
11:14:08 web.1       |   rack-cache (1.2) lib/rack/cache/context.rb:155:in `invalidate'
11:14:08 web.1       |   rack-cache (1.2) lib/rack/cache/context.rb:71:in `call!'
11:14:08 web.1       |   rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   rack-timeout (0.1.1) lib/rack/timeout.rb:104:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   railties (4.0.13) lib/rails/engine.rb:511:in `call'
11:14:08 web.1       |   railties (4.0.13) lib/rails/application.rb:97:in `call'
11:14:08 web.1       |   newrelic_rpm (3.9.9.275) lib/new_relic/agent/instrumentation/middleware_tracing.rb:57:in `call'
11:14:08 web.1       |   passenger (4.0.57) lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
11:14:08 web.1       |   passenger (4.0.57) lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
11:14:08 web.1       |   passenger (4.0.57) lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
11:14:08 web.1       |   passenger (4.0.57) lib/phusion_passenger/request_handler.rb:455:in `block (3 levels) in start_threads'
11:14:08 web.1       | App 29025 stderr: cache: [POST /mini-profiler-resources/results] invalidate, pass

@akshetpandey
Copy link

+1. The ruby process hangs in what seems like an infinite loop. and the POST for result never returns, making both the server and the gem unusable.

INFO  : Started POST "/mini-profiler-resources/results" for 127.0.0.1 at 2015-01-19 19:55:01 +0530
FATAL : 
SystemStackError - stack level too deep:
  actionpack (4.1.6) lib/action_dispatch/middleware/reloader.rb:79:in `'

INFO  : Started POST "/mini-profiler-resources/results" for 127.0.0.1 at 2015-01-19 19:55:02 +0530
FATAL : 
SystemStackError - stack level too deep:
  actionpack (4.1.6) lib/action_dispatch/middleware/reloader.rb:79:in `'

This issue is with the fact that I am using OJ and oj_mimic_json and OJ doesn't handle circular dependency.

@seanlinsley
Copy link
Contributor

Ruby's JSON serialization doesn't handle circular references, which is why another gem I've worked on included their own implementation.

Though in this situation we control all of the data, so we should be able to get rid of the circular reference instead of resorting to that.

@zapo
Copy link

zapo commented Dec 12, 2015

I fixed it naively by monkey patching TimerStruct::Base with this rails'ism

module Rack
  class MiniProfiler
    module TimerStruct
      class Base
        def as_json
          @attributes
        end
      end
    end
  end
end

@wojtha
Copy link

wojtha commented Mar 11, 2016

@SamSaffron I put together solutions from @emaillenin @zapo and I'm able to finally use Oj and Miniprofiler together. Thank you guys!

Gemfile

gem 'rack-mini-profiler', group: 'development', require: false 

config/initializers/miniprofiler.rb

if Rails.env.development?
  require 'rack-mini-profiler'

  # Fix circular ref conflict with Oj.mimic_json
  module Rack
    class MiniProfiler
      module TimerStruct
        class Base
          def as_json
            @attributes
          end
        end
      end
    end
  end

  # Initialization is skipped so trigger it
  Rack::MiniProfilerRails.initialize!(Rails.application)
end

@kbrock
Copy link
Contributor

kbrock commented Apr 17, 2016

So is the thought to add this monkey patch directly to the source? Or to put in a patch to oj? Or modify our data structure to remove the circular dependency?

@peterkeen
Copy link

Bump. I would lean toward removing the circular dependency.

@dgynn
Copy link
Contributor

dgynn commented Sep 13, 2016

The circular dependency was removed in #250 and is fixed on master. This issue can probably be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants