Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Stack level too deep #47

Open
satb opened this issue May 23, 2013 · 2 comments
Open

Stack level too deep #47

satb opened this issue May 23, 2013 · 2 comments

Comments

@satb
Copy link

satb commented May 23, 2013

See issue # 23 in which I was asked to open a new issue. This is still a problem.

Using JRuby 1.7.2 and rails 3.2.12. I am using the "closure_tree" gem that has some sort of recursion. Don't know if that is causing this.

SystemStackError - stack level too deep:
org/jruby/RubyProc.java:261:in call' org/jruby/RubyProc.java:249:incall'
org/jruby/RubyHash.java:681:in default' org/jruby/RubyHash.java:1070:in[]'
(gem) actionpack-3.2.12/lib/action_view/template/resolver.rb:127:in query' org/jruby/RubyArray.java:2595:inreject!'
org/jruby/RubyArray.java:2558:in reject' (gem) actionpack-3.2.12/lib/action_view/template/resolver.rb:126:inquery'
(gem) actionpack-3.2.12/lib/action_view/template/resolver.rb:117:in find_templates' (gem) actionpack-3.2.12/lib/action_view/template/resolver.rb:46:infind_all'
(gem) actionpack-3.2.12/lib/action_view/template/resolver.rb:77:in cached' (gem) actionpack-3.2.12/lib/action_view/template/resolver.rb:45:infind_all'
(gem) actionpack-3.2.12/lib/action_view/path_set.rb:65:in find_all' org/jruby/RubyArray.java:1613:ineach'
(gem) actionpack-3.2.12/lib/action_view/path_set.rb:64:in find_all' org/jruby/RubyArray.java:1613:ineach'
(gem) actionpack-3.2.12/lib/action_view/path_set.rb:63:in find_all' (gem) actionpack-3.2.12/lib/action_view/path_set.rb:58:infind'
(gem) actionpack-3.2.12/lib/action_view/lookup_context.rb:109:in find' (gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:79:insource'
(gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:43:in digest' (gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:32:indigest'
(gem) activesupport-3.2.12/lib/active_support/cache.rb:297:in fetch' (gem) activesupport-3.2.12/lib/active_support/cache.rb:520:ininstrument'
(gem) activesupport-3.2.12/lib/active_support/cache.rb:296:in fetch' (gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:31:indigest'
(gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:85:in dependency_digest' org/jruby/RubyArray.java:2348:incollect'
org/jruby/RubyArray.java:2356:in collect' (gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:84:independency_digest'
(gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:43:in digest' (gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:32:indigest'
(gem) activesupport-3.2.12/lib/active_support/cache.rb:297:in fetch' (gem) activesupport-3.2.12/lib/active_support/cache.rb:520:ininstrument'
(gem) activesupport-3.2.12/lib/active_support/cache.rb:296:in fetch' (gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:31:indigest'
(gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:85:in dependency_digest' org/jruby/RubyArray.java:2348:incollect'
org/jruby/RubyArray.java:2356:in collect' (gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:84:independency_digest'
(gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:43:in digest' (gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:32:indigest'
(gem) activesupport-3.2.12/lib/active_support/cache.rb:297:in fetch' (gem) activesupport-3.2.12/lib/active_support/cache.rb:520:ininstrument'
(gem) activesupport-3.2.12/lib/active_support/cache.rb:296:in fetch' (gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:31:indigest'
(gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:85:in dependency_digest' org/jruby/RubyArray.java:2348:incollect'
org/jruby/RubyArray.java:2356:in collect' (gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:84:independency_digest'
(gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:43:in digest' (gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:32:indigest'
(gem) activesupport-3.2.12/lib/active_support/cache.rb:297:in fetch' (gem) activesupport-3.2.12/lib/active_support/cache.rb:520:ininstrument'
(gem) activesupport-3.2.12/lib/active_support/cache.rb:296:in fetch' (gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:31:indigest'
(gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:85:in dependency_digest' org/jruby/RubyArray.java:2348:incollect'
org/jruby/RubyArray.java:2356:in collect' (gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:84:independency_digest'
(gem) cache_digests-0.2.0/lib/cache_digests/template_digestor.rb:43:in `digest'

Not having issues if I remove "cache_digests". It works without causing the "stack too deep" problem with just fragment caching

application.html.erb has:

<% root_children = Category.root.children %>
                    <% cache "menu" do %>
                        <ul class="nav">
                          <% root_children.each do |c| %>
                            <%= render partial: "categories/menu", locals: {category: c} %>
                          <% end %>
                        </ul>
                    <% end %>

category/_menu.html.erb

<% if not (category.leaf?) %>
    <li class="dropdown">
      <a data-toggle="dropdown" class="dropdown-toggle" href="#"><%= category.name %><span class="caret"></span></a>
      <ul class="dropdown-menu">
        <li>
            <%= link_to "All #{pluralize("", category.name)}'", items_path(category_id: category)  %>
        </li>
        <% category.children.each do |c| %>
            <%= render partial: "categories/menu", locals: {category: c} %>
        <% end %>
      </ul>
    </li>
<% else %>
    <%= render partial: "categories/menu_item", locals: {category: category} %>
<% end %>

category/_menu_item.html.erb

<li>
  <%= link_to "#{category.name}", items_path(category_id: category) %>
</li>
@mupkoo
Copy link

mupkoo commented Oct 30, 2013

I have the same issue, using Rails 4.0.0. When I try to cache a segment with recursion, I get this error:

SystemStackError at /testing-webcast/sections
=============================================

> stack level too deep

activesupport (4.0.0) lib/active_support/notifications/instrumenter.rb, line 23

Here is the code from my app

models/section.rb

class Section < ActiveRecord::Base

    ...

    # Relations
    belongs_to :webcast
    belongs_to :speaker
    belongs_to :parent, class_name: Section
    has_many :children, class_name: Section, foreign_key: :parent_id

    # Scopes
    default_scope -> { order(:position) }
    scope :root, -> { where parent_id: nil }

    ....

end

sections/_webcast.html.erb

<% cache [ 'sections', sections.maximum(:updated_at).to_i ] do %>
    <%= render 'sections/list', sections: sections.root %>
<% end %>

sections/_list.html.erb

<ul>
    <% sections.each do |section| %>
        <li>
            <div class="section webcast animate">
                <h2><%= section.get_title %></h2>
            </div>

            <% if section.children.count > 0 %>
                <%= render 'sections/list', sections: section.children %>
            <% end %>
        </li>
    <% end %>
</ul>

Everything works, if I remove this part.

...
<% if section.children.count > 0 %>
    <%= render 'sections/list', sections: section.children %>
<% end %>
...

Other thing is that, after I remove the part from above, the cache is created.
After this I add the part again to the template, remove the cache manually (delete the files)
and it starts to work.

@charles
Copy link

charles commented Mar 13, 2014

Try this way...

<% if section.children.count > 0 %>
<%= render sections: section.children, partial: 'sections/list' %>
<% end %>

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

No branches or pull requests

3 participants