jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • JRuby
  • JRUBY-3289

ArgumentError: dump format error() when unmarshalling Rails session and EOFError when unmarshalling hash with containing value of type ActionController::Flash::FlashHash

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.1.6
  • Fix Version/s: JRuby 1.2
  • Component/s: Core Classes/Modules
  • Labels:
    None
  • Environment:
    OSX 10.5.6, Rails 1.2.3, Rails 2.2.2, MRI 1.8.5
  • Testcase included:
    yes

Description

In an attempt to port a Rails 1.2.3 application to JRuby I encountered this message when the session was unmarshalled:

ArgumentError: dump format error()

Here's a simple test case that produces the same result, though with a different error thrown:

rails_flash =  ActionController::Flash::FlashHash.new
test_hash = {:flash =>rails_flash, :date => Date.today}
dump_test = Marshal.dump(test_hash)
loaded = Marshal.load(dump_test)

As opposed to a normal Hash which executes as expected:

normal_hash = Hash.new
test_hash = {:normal => normal_hash, :date => Date.today}
dump_test = Marshal.dump(test_hash)
loaded = Marshal.load(dump_test)

I've executed in Rails 1.2.3 and Rails 2.2.2 via the console, they both fail. However, these work flawlessly when invoked with MRI 1.8.5. See attached test case.

UnmarshalStream Findings

Here's the marshalled string:

"\004\b{\a:\nflashIC:'ActionController::Flash::FlashHash{\000\006:\n@used{\000:\tdateu:\tDate=\004\b[\bo:\rRational\a:\021@denominatori\a:\017@numeratori\003k?Ji\000i\003\031\025#"

I downloaded the JRuby source and think I have identified the problem in UnmarshalStream. I've stepped through the JRuby code multiple times now and have a grasp on the cause of the failure, but I don't have a patch. When the ActionController::Flash::FlashHash instance is being unmarshalled in unmarshalObjectDirectly, isvarsWaiting is set to true (due to the I from the marshalled FlashHash) and, as far as these tests go, is never reset to false. In the session unmarshalling case, when the Date object is parsed and the \031 character is read, it fails the switch case and the ArgumentError is raised. In the provided test case,

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. File
    fix_unmarshal.diff
    05/Feb/09 10:12 PM
    3 kB
    László Bácsi
  2. File
    jruby_hash_subclass_test.rb
    07/Jan/09 11:12 AM
    1 kB
    Russ Rollins
  3. File
    jruby_marshal_flashhash_test.rb
    06/Jan/09 6:33 PM
    1 kB
    Russ Rollins

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Russ Rollins added a comment - 07/Jan/09 11:11 AM

I've created a non-Rails test case that more fully illustrates the ArgumentError: dump format error(). I'll attach the new test case (jruby_hash_subclass_test.rb). This file clearly shows the marshalling bug occurs when when a subclassed Hash has instance variables.

Show
Russ Rollins added a comment - 07/Jan/09 11:11 AM I've created a non-Rails test case that more fully illustrates the ArgumentError: dump format error(). I'll attach the new test case (jruby_hash_subclass_test.rb). This file clearly shows the marshalling bug occurs when when a subclassed Hash has instance variables.
Hide
Permalink
Nick Sieger added a comment - 30/Jan/09 9:47 AM

Marking as should-fix for 1.2. Assigned to myself for now.

Show
Nick Sieger added a comment - 30/Jan/09 9:47 AM Marking as should-fix for 1.2. Assigned to myself for now.
Hide
Permalink
Clemens added a comment - 05/Feb/09 3:02 AM

"Same" problem
WinXP, JRuby 1.1.6, Rails 2.1.2,

BUT only occurs (randomly) when running cucumber tests (features) with rcov(1.8.5.0-java). So it might be another problem...

Exact stack dump:
dump format error() (ArgumentError)
D:/NetBeans/ruby2/jruby-1.1.6/bin/../lib/ruby/1.8/cgi/session.rb:304:in `[]'
D:/projects/passdate2009/src/vendor/plugins/webrat/lib/webrat/rails/rails_session.rb:19:in `get'
D:/projects/passdate2009/src/vendor/plugins/webrat/lib/webrat/core/session.rb:60:in `request_page'
D:/projects/passdate2009/src/vendor/plugins/webrat/lib/webrat/core/session.rb:118:in `visits'
D:/projects/passdate2009/src/vendor/plugins/webrat/lib/webrat/rails/session.rb:15:in `method_missing'
features/steps/ispid_signin_steps.rb:2:in ` /ISPID meldet sich an als "(.*)"$/'
features/forbidden_things.feature:10:in `/ISPID meldet sich an als "(.*)"$/'

Show
Clemens added a comment - 05/Feb/09 3:02 AM "Same" problem WinXP, JRuby 1.1.6, Rails 2.1.2, BUT only occurs (randomly) when running cucumber tests (features) with rcov(1.8.5.0-java). So it might be another problem... Exact stack dump: dump format error() (ArgumentError) D:/NetBeans/ruby2/jruby-1.1.6/bin/../lib/ruby/1.8/cgi/session.rb:304:in `[]' D:/projects/passdate2009/src/vendor/plugins/webrat/lib/webrat/rails/rails_session.rb:19:in `get' D:/projects/passdate2009/src/vendor/plugins/webrat/lib/webrat/core/session.rb:60:in `request_page' D:/projects/passdate2009/src/vendor/plugins/webrat/lib/webrat/core/session.rb:118:in `visits' D:/projects/passdate2009/src/vendor/plugins/webrat/lib/webrat/rails/session.rb:15:in `method_missing' features/steps/ispid_signin_steps.rb:2:in ` /ISPID meldet sich an als "(.*)"$/' features/forbidden_things.feature:10:in `/ISPID meldet sich an als "(.*)"$/'
Hide
Permalink
László Bácsi added a comment - 05/Feb/09 10:12 PM

Russ was right, not setting the ivarsWaiting variable back to false caused the issue. I created a patch with the fix and the tests for this.

Show
László Bácsi added a comment - 05/Feb/09 10:12 PM Russ was right, not setting the ivarsWaiting variable back to false caused the issue. I created a patch with the fix and the tests for this.
Hide
Permalink
Nick Sieger added a comment - 07/Feb/09 6:19 PM

Thanks for the patch!

Show
Nick Sieger added a comment - 07/Feb/09 6:19 PM Thanks for the patch!

People

  • Assignee:
    Nick Sieger
    Reporter:
    Russ Rollins
Vote (0)
Watch (2)

Dates

  • Created:
    06/Jan/09 6:33 PM
    Updated:
    21/Mar/09 1:14 PM
    Resolved:
    07/Feb/09 6:19 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.