rubinius/rubinius — Issue #1522: Marshal error with hash that was shrunk using `reject!`
Author: mislav
Created: 2012-01-18 20:49:04+00:00
State: open

Gather 'round folks and witness Marshal.load choke on the Incredible Shrinking Hash™!

~~~ rb
env = { }

# first it grows:
('a'..'c').each {|k| env[k] = nil }
('A'..'Z').each {|k| env[k * 3] = "" }

Marshal.load Marshal.dump(env) # => works

# then it shrinks:
env.reject! { |k,v| !v.respond_to? :to_str }

Marshal.load Marshal.dump(env) # ERROR in rbx 1.8 mode
~~~

The error:

~~~
Exception: `ArgumentError' kernel/common/marshal.rb:469 - load error, unknown type 0
kernel/common/marshal.rb:380:in `construct'
kernel/common/marshal.rb:469:in `construct_hash'
kernel/common/integer.rb:87:in `times'
kernel/common/marshal.rb:468:in `construct_hash'
kernel/common/marshal.rb:326:in `construct'
kernel/common/marshal.rb:973:in `load'
~~~