Colin Bartlett created JRUBY-6612:
-------------------------------------
Summary: some problems with JRuby seeming to not detect Java Long
arithmetic overflows
Key: JRUBY-6612
URL: https://jira.codehaus.org/browse/JRUBY-6612
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.6.6
Environment: Laptop running Microsoft Windows Vista and a netbook
running Microsoft Windows 7
Reporter: Colin Bartlett
Attachments: qjrubyfixnum.rb
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.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email