Skip to content

Instantly share code, notes, and snippets.

@bendilley
Created February 10, 2015 17:41
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bendilley/1453a555e981ed533f68 to your computer and use it in GitHub Desktop.
Save bendilley/1453a555e981ed533f68 to your computer and use it in GitHub Desktop.
Get a trace from a 'stack too deep' error in Rails
$enable_tracing = false
#$trace_out = File.open(Rails.root + 'trace.txt', 'w')
set_trace_func proc { |event, file, line, id, binding, classname|
if $enable_tracing && event == 'call'
#$trace_out.puts "#{file}:#{line} #{classname}##{id}"
raise "crash me" if caller_locations.length > 500
end
}
$enable_tracing = true
@bendilley
Copy link
Author

@badbabykosh it's been a long time since I used this initialiser. It should only be necessary if for some reason you haven't got the backtrace already. Stack overflows are nearly always caused by recursive loops, so you should see repeats of the same method sequence over and over in the backtrace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment