Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6.6
-
Fix Version/s: JRuby 1.7.0.pre1
-
Component/s: Core Classes/Modules
-
Labels:None
-
Environment:Laptop running Microsoft Windows Vista and a netbook running Microsoft Windows 7
-
Number of attachments :
Description
There seem to be some bugs where the Java code underlying JRuby seems to not detect Long arithmetic overflows.
For example, on my PCs running this code in JRuby:
nn = -(2**63)-1
3.times {|i| i += nn; puts "# i: #{i}; i*-1: #{i*-1}; -1*i: #{-1*i}" }
results in this output:
# i: -9223372036854775809; i*-1: 9223372036854775809; -1*i: 9223372036854775809 # i: -9223372036854775808; i*-1: 9223372036854775808; -1*i: -9223372036854775808 # i: -9223372036854775807; i*-1: 9223372036854775807; -1*i: 9223372036854775807
I seem to have some problems with Fixnum multiplication (as above),
and with Fixnum/Bignum Range#each and Range#each_with_index.
There are more examples and information in the attached JRuby file.
My apologies if I am making a mistake, or if these issues have been raised before: I searched jira.codehaus.org using "JRuby overflow", but didn't find anything that seemed to cover the examples in the attached file.
I wasn't sure what priority to give this: if I'm correct that these are bugs with Fixnum (etc) then they would seem to be "major", but if no-one else has noticed these before then in practice there hasn't so far been a problem
.
In the attached file I've put a possible patch for one occurrence of the Fixnum multiply overflow problem, but there may be other places where patches are needed, and there is also the Fixnum/Bignum range problem: I'm afraid I haven't looked at all at the JRuby Java code for that.
I would be happy to give more details and/or answer any questions.
Update: I've just downloaded
http://jruby.org.s3.amazonaws.com/downloads/1.6.7/jruby-bin-1.6.7.zip
and the issues in my original post about JRuby 1.6.6 seem to also be in 1.6.7.
I've also done a better search, and found these, which may be relevant:
http://jira.codehaus.org/browse/JRUBY-3566
http://jira.codehaus.org/browse/JRUBY-6307
http://jira.codehaus.org/browse/JRUBY-6518