Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

2.3.2 marshalling problem - Browser shows error 500

#2443

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.

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

State: invalid
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Eric Perko
    Eric Perko

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

    May 18th, 2009 @ 04:54 PM

  2. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from 2.3.2 to 2.3.2, bugmash

    August 6th, 2009 @ 02:44 PM

  3. John Pignata
    John Pignata

    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.

    August 9th, 2009 @ 01:47 PM

  4. Elad Meidar
    Elad Meidar

    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)

    August 9th, 2009 @ 04:07 PM

  5. Rizwan Reza
    Rizwan Reza

    not reproducible

    -1 Agreed with John.

    August 9th, 2009 @ 11:22 PM

  6. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to invalid
    • Tag changed from 2.3.2, bugmash to 2.3.2
    • Milestone cleared.

    August 9th, 2009 @ 11:23 PM

  7. Eric Perko
    Eric Perko

    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.

    March 26th, 2010 @ 08:15 PM