"SystemStackError: stack level too deep" since 3.0.3 #260

rfc2822 opened this Issue Jun 5, 2011 · 17 comments


None yet

rfc2822 commented Jun 5, 2011

I have a standard authlogic configuration like in the tutorial. From version 3.0.3, I get

SystemStackError: stack level too deep

but only in the production mode. I can reproduce it with:

RAILS_ENV=production rails c
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
p = MyModelsSession.find

SystemStackError: stack level too deep
from /my/project/vendor/bundler/ruby/1.8/gems/activesupport-3.0.8.rc4/lib/active_support/core_ext/class/attribute.rb:73:in acts_as_authentic_config' from /my/project/vendor/bundler/ruby/1.8/gems/authlogic-3.0.3/lib/authlogic/session/foundation.rb:21:inrw_config'
from /my/project/vendor/bundler/ruby/1.8/gems/authlogic-3.0.3/lib/authlogic/session/foundation.rb:22:in rw_config' from /my/project/vendor/bundler/ruby/1.8/gems/authlogic-3.0.3/lib/authlogic/session/password.rb:90:inlogin_field'
from /my/project/vendor/bundler/ruby/1.8/gems/authlogic-3.0.3/lib/authlogic/session/password.rb:213:in login_field' from /my/project/vendor/bundler/ruby/1.8/gems/authlogic-3.0.3/lib/authlogic/session/password.rb:118:ininitialize'
from /my/project/vendor/bundler/ruby/1.8/gems/authlogic-3.0.3/lib/authlogic/session/activation.rb:48:in initialize' from /my/project/vendor/bundler/ruby/1.8/gems/authlogic-3.0.3/lib/authlogic/session/klass.rb:64:ininitialize'
from /my/project/vendor/bundler/ruby/1.8/gems/authlogic-3.0.3/lib/authlogic/session/scopes.rb:79:in initialize' from /my/project/vendor/bundler/ruby/1.8/gems/authlogic-3.0.3/lib/authlogic/session/persistence.rb:37:innew'
from /my/project/vendor/bundler/ruby/1.8/gems/authlogic-3.0.3/lib/authlogic/session/persistence.rb:37:in `find'
from (irb):2

Can you please audit /my/project/vendor/bundler/ruby/1.8/gems/authlogic-3.0.3/lib/authlogic/session/foundation.rb:21 ff? Maybe there's a case when it causes an infinite loop? I think so.

pdkl95 commented Jun 6, 2011

I'm getting this issue as well. It took me the last day to even figure out it was a problem in authlogic, as the stack trace would just say "SystemStackError" with no useful data in it.

[I had just moved things to rvm, and thought it was related to that for most of the time]

I've now been able to isolate it specifically to the call to Session.find(), similar to the above. Now i guess it's time to digh through foundation.rb and see what's broken...

EDIT: ok, it seems that reverting lines 20-27 in foundation.rb fixes it, at least as a temporary workaround. I have yet to see if that has any other interactions.

I also got this.

Encountered this issue using Rails v3.0.8 and Authlogic v3.0.3. Reverting to Authlogic v3.0.2 fixed this issue for the time being.

rdj commented Jun 18, 2011

Agree, commit c569334 is the problem.

I have worked around with this in my Gemfile:

gem 'authlogic', :git => 'git://github.com/binarylogic/authlogic.git', :ref => '0297e1c005c626c1e37b'

This refs the commit right before the pull request from AndreasWurm was merged, and now my Rails3.1-rc4 seems to be working correctly.

Yep I just hit this too. Took me entirely too long to debug this to the point where I found this bug, as it came up in the context of other major refactoring. Would be great to get a fix in the next version, though I'm not comfortable enough with Rails 3.1 to dig into it myself.

jared commented Aug 17, 2011

I've just encountered this bug this evening on Rails 3.1.0rc5 and authlogic 3.0.3.

rdj commented Sep 1, 2011

Just bumping to mention this problem still manifests when using the new 3.1.0 released rails gem with the 3.0.3 authlogic gem. Referencing 0297e1c directly from git is still a good workaround.

I have the same problem...I will try referencing, thanks for putting the full code @rdj

@stephenprater stephenprater added a commit to stephenprater/authlogic that referenced this issue Dec 29, 2011

@stephenprater stephenprater fixes issues #260 41eba3d

keynan commented Jan 26, 2012

Has this issue been fixed in a version that supports Rails 3.1 or 3.2

Denommus commented May 4, 2012

The issue still happens on version 3.1, with Rails 3.2.

Trying to use the commit 0297e1c doesn't solve the problem, it gives a big error (related to the fact that 'inheritable_attributes' doesn't exist anymore).

sunchess commented May 7, 2012

Yes, I have the problem too. To me, the bug is in rspec tests. I don't run on production yet.

Ran into this, this morning, trying to get a copy of my app setup on a windows server as a test. I've been running it in production on Heroku for months though without incident... Not sure if Heroku is dealing with it somehow though.

I tried the commit mentioned, but had the same problem as Denommus had.

I had reproduced this in Authlogic 3.1.0 and Rails 3.2.12

aeldaly commented May 2, 2013

Any updates on this?

After taking matters into my own hands, I've isolated the problem for me. If your crypted_password_field is "password", then you end up in an infinite loop. Please see this method for the details:

def password=(pass)
return if ignore_blank_passwords? && pass.blank?
@password = pass
send("#{password_salt_field}=", Authlogic::Random.friendly_token) if password_salt_field
send("#{crypted_password_field}=", crypto_provider.encrypt(*encrypt_arguments(@password, false, act_like_restful_authentication? ? :restful_authentication : nil)))
@password_changed = true

raelik commented Dec 9, 2013

Still having this issue with Authlogic 3.1.3 and Rails 3.2.6 to 3.2.16. Oddly, it only happens on one of my controllers, that isn't functionally different from my other controllers.

Having this issue right now. Any updates?

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