Question

I have a 3.0.7 app using active scaffold from github vhochstein/master. I am using the 3.x compatible version which can be used as a vendor/plugin, rather than requiring gem-installation.

In production it hits ActionView::Template::Error (stack level too deep):.

beaumont@edouard:~/beaumont/current$ script/rails server -p 4000
ActionView::Template::Error (stack level too deep):
    8:  depth = Kernel.caller.count
    9:  logger.info "pagination: #{@page} #{depth}" 
    10: %>
    11:     <%= render :partial => 'list_pagination_links', :locals => { :current_page => @page } if @page.pager.infinite? || @page.pager.number_of_pages > 1 %>
    12:   </div>
    13:   <br clear="both" /><%# a hack for the Rico Corner problem %>
    14: </div>

I started by looking for some recursion in my code, and then for cycle in my data model that was screwing up AS. It happened first with mod_passenger, but it also occurs with script/rails server running logged into the server. (This is my beta test machine)

It always dies in Rendered vendor/plugins/active_scaffold/frontends/default/views/_list_pagination.html.erb(144.3ms 157). I hacked ActionView to log the Kernel.caller.count so that I could see if a stack was growing and growing but I don't see this. I do see stack depths as high as 180. It doesn't seem matter if I ulimit -s the stack bigger before starting rails, but maybe something ulimits the stack back again.

In _list_pagination.html.erb, it calls list_pagination_links. If I comment out that calls, then things do not fail. I tried making list_pagination_links do nothing (having not code in it!), but it still died at that render call. I wonder if it's in the render code itself that the stack is either going recursive, or just something too big.

This does not happen on my laptop (debian sequeeze, 32-bit) in development mode, but does happen on my beta production machine (XEN VM, 32-bit, debian squeeze). It did occur on my laptop at times, but not in a repeatable fashion, and restarting rails "solved" the problems. I haven't tried production mode on my laptop yet, and I also suspect that it may be data dependent!

Was it helpful?

Solution

A desperate debugging method useful for these cases that I discovered when dealing with the exact same problem is the Kernel's set_trace_func method.

It basically sets a method to be called after each interpreter "action". If tou use this to print some info, then it can get pretty verbose, your program becomes annoyingly slow, but you can see exactly what's going on. And if it's really an infinite recursion, then you would see the name of the function that misbehaved fill your screen in a second.

An example of use in your case would be:

 <% set_trace_func proc { |event, file, line, id, binding, classname|
        printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
      } %>
<%= render :partial => 'list_pagination_links', :locals => { :current_page => @page } if @page.pager.infinite? || @page.pager.number_of_pages > 1 %>
<% set_trace_func nil # disables tracing%>

Link to the set_trace_func doc

ps: I know that this is not an answer in its real sense, but it was too long to post as a comment

OTHER TIPS

When I was debugging the infinite paging issue in Active Scaffold, I added:

require 'active_scaffold/extensions/paginator_extensions'

to my code. This line seems to be the cause. I don't know why.

git bisect and line by line removal of code found this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top