Skip to content

Marshal dump produces wrong output for Range objects #5805

@Confusion

Description

@Confusion

Environment

jruby 9.2.7.0 (2.5.3) 2019-04-09 8a269e3 OpenJDK 64-Bit Server VM 11.0.3+7-Ubuntu-1ubuntu218.04.1 on 11.0.3+7-Ubuntu-1ubuntu218.04.1 +jit [linux-x86_64]

No gems, no framework, no relevant ENV.

Expected Behavior

2.5.3 :001 > Marshal.dump(1..2)
 => "\x04\bo:\nRange\b:\texclF:\nbegini\x06:\bendi\a"

Actual Behavior

jruby-9.2.7.0 :001 > Marshal.dump((1..2))
 => "\x04\bo:\nRange\b:\vbeginii\x06:\tendii\a:\texclF"

This is problematic, because

2.5.3 :001 > Marshal.load("\x04\bo:\nRange\b:\vbeginii\x06:\tendii\a:\texclF")
 => nil..nil 
2.6.3 :001 > Marshal.load("\x04\bo:\nRange\b:\vbeginii\x06:\tendii\a:\texclF")
 => nil.. 

Notes

Discovered because we are using DRb to communicate between a Ruby 2.5.3 and JRuby 9.2.7.0 process, where it turns out Range objects get mangled.

JRuby does deserialize the result of MRI Marshal.dump correctly:

jruby-9.2.7.0 :001 > Marshal.load("\x04\bo:\nRange\b:\texclF:\nbegini\x06:\bendi\a")
 => 1..2 

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions