Details
-
Type:
Task
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6RC1
-
Fix Version/s: JRuby 1.7.0.pre1
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:jruby 1.6.0.RC1 (ruby 1.8.7 patchlevel 330) (2011-01-12 71f8afd) (OpenJDK 64-Bit Server VM 1.6.0_20) [linux-amd64-java]
-
Number of attachments :
Description
CRuby's Random (uses Mersenne Twister) serializes it's state, left bytes and seed for restoring PRNG's state. We don't support PRNG state dump/load at present.
So Random's marshal format is incompatible. It would affect to dRuby, etc if one want to Marshal PRNG, I think it's a rare case though.
0% jruby --1.9 -e 'print Marshal.dump(Random.new)' | ruby -e 'p Marshal.load(STDIN)' -e:1:in `marshal_load': wrong argument type Random (expected Bignum) (TypeError) from -e:1:in `load' from -e:1:in `<main>' 0% jruby -v jruby 1.6.0.RC1 (ruby 1.8.7 patchlevel 330) (2011-01-12 71f8afd) (OpenJDK 64-Bit Server VM 1.6.0_20) [linux-amd64-java] 0% ruby -v ruby 1.9.3dev (2011-01-11 trunk 30513) [x86_64-linux]
By definition, we cannot let it be compatible without implementing exactly the same Mersenne Twister logic as CRuby. Take care, it could cause security issues.
Shall we do this?
It looks like Marcin did port the Mersenne Twister logic to org.jruby.util.Random at one point, but never hooked it up. I asked him about it, and he said 1.9's logic was still evolving at that point.
So in theory, if we can confirm that our Twister logic is sound, it's a matter of porting the random.c logic into RubyRandom.
Nahi: Since you filed, this, I'm putting the ball in your court to decide what we should do. I personally don't have a problem with Random marshaling differently than 1.9, since it seems like a very peculiar thing to marshal in the first place. But you may have a different opinion...so I leave it up to you.