This project is archived and is in readonly mode.

#2443 ✓invalid
rpdevelop (at gmail)

2.3.2 marshalling problem - Browser shows error 500

Reported by rpdevelop (at gmail) | April 7th, 2009 @ 05:24 PM

Browser shows error 500. The same code runs smoothly in 2.2.2. This is what happens: After the action in controller is executed the code eventually

ends up in CookieOverflow.marshal(session)--->

module: ActionController,Session class:CookieOverflow

def marshal(session)

      @verifier.generate(persistent_session_id!(session))

end

The "@verifier" is MessageVerifier, so in "marshal" method the MessageVerifier's "generate" method is called and the "session" is

passed to it in "value" parameter.--->

module: ActiveSupport class: MessageVerifier

def generate(value)

  data = ActiveSupport::Base64.encode64s(Marshal.dump(value))
  "#{data}--#{generate_digest(data)}"

end

In my example "value" is hash (length=6), so it is small.
But the statement "Marshal.dump(value)" generates string (size over 3,5K) and later on few things get added and the generated data grows over to 4638 in my case. Back in "CookieOverflow" this data gets check against MAX 4096 and since it is over this max (I assume the max length allowed for session) the error 500 gets thrown.

Comments and changes to this ticket

  • Eric Perko

    Eric Perko May 18th, 2009 @ 04:54 PM

    Did you resolve this problem? I am experiencing the same error on Rails 2.3.2

  • CancelProfileIsBroken

    CancelProfileIsBroken August 6th, 2009 @ 02:44 PM

    • Tag changed from 2.3.2 to 2.3.2, bugmash
  • John Pignata

    John Pignata August 9th, 2009 @ 01:47 PM

    I could not replicate this using a small hash of six strings. It's possible that one of your six hash members is a large object and is being marshaled into something huge? I'd first check exactly what I'm putting into session and understand why it's generating so much data. If this is unavoidable, use active_record_store instead of cookie store.

  • Elad Meidar

    Elad Meidar August 9th, 2009 @ 04:07 PM

    I think that's expected, obviously one of the values in your hash resolves to a large string, simply because it's a large object, can you check what is in your hash? i was unable to replicate it using:

    • hash of strings (length = 6)
    • hash of simple, small instances of a model (length = 6)
    • hash of 1 char strings (length = 500)
  • Rizwan Reza

    Rizwan Reza August 9th, 2009 @ 11:22 PM

    not reproducible

    -1 Agreed with John.

  • Jeremy Kemper

    Jeremy Kemper August 9th, 2009 @ 11:23 PM

    • State changed from “new” to “invalid”
    • Tag changed from 2.3.2, bugmash to 2.3.2
    • Milestone cleared.
  • Eric Perko

    Eric Perko March 26th, 2010 @ 08:15 PM

    For future reference, I finally got around to looking into this problem and was able to figure it out. In a nutshell, our session was holding an entire ActiveRecord object, not just its ID (which was a bad idea anyways). Because of this, the newer marshalling code in Rails 2.3 was trying to serialize enough data to put the object back together later. This worked for some users, but for the majority, eventually a query or two loaded up some associations for the object in the session; loading up associations made for even more data that marhsal thought it needed to serialize. Eventually, some functionality queried enough to pull in a huge chunk of data, causing marshal to go from outputting about 2KB to like 25KB. If anyone experiences this in the future, try changing out the ActiveRecord object for just the ID and see if that fixes your problem.

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>

Tags

Pages