This project is archived and is in readonly mode.

#2108 ✓resolved
Wincent Colaiuta

reset_session causes rack exception if session blank

Reported by Wincent Colaiuta | March 1st, 2009 @ 07:59 PM

I had a controller action in 2.2.2 which contained "reset_session":


def destroy
  reset_session
end

Now in 2.3.0 RC1 that line bails with a lengthy stack trace:


/!\ FAILSAFE /!\  Sun Mar 01 20:35:31 +0100 2009
  Status: 500 Internal Server Error
  You have a nil object when you didn't expect it!
The error occurred while evaluating nil.data=
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/activerecord/lib/active_record/session_store.rb:300:in `set_session'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/activerecord/lib/active_record/base.rb:1454:in `silence'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/activerecord/lib/active_record/session_store.rb:298:in `set_session'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/actionpack/lib/action_controller/session/abstract_store.rb:116:in `call'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/actionpack/lib/action_controller/failsafe.rb:11:in `call'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/actionpack/lib/action_controller/rack_ext/lock.rb:15:in `call'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/actionpack/lib/action_controller/rack_ext/lock.rb:15:in `synchronize'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/actionpack/lib/action_controller/rack_ext/lock.rb:15:in `call'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:83:in `call'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/railties/lib/rails/rack/static.rb:27:in `call'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/railties/lib/rails/rack/log_tailer.rb:17:in `call'
    /Library/Ruby/Gems/1.8/gems/rack-0.9.1/lib/rack/handler/mongrel.rb:59:in `process'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:159:in `process_client'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:158:in `each'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:158:in `process_client'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `run'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `initialize'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `new'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:285:in `run'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `initialize'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `new'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/lib/mongrel.rb:268:in `run'
    /Library/Ruby/Gems/1.8/gems/rack-0.9.1/lib/rack/handler/mongrel.rb:32:in `run'
    /Users/wincent/trabajo/unversioned/wincent.com/src/vendor/rails/railties/lib/commands/server.rb:100
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    script/server:3

Workaround is:


def destroy
  reset_session unless session.blank?
end

Currently trying to come up with a minimal test case to reproduce.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Referenced by

Pages