10.8 Ruby: Bignum seems to be broken

Originator:kimuraw
Number:rdar://11806241 Date Originated:05-Jul-2012 12:31 AM
Status:Open Resolved:
Product:Mac OS X Product Version:10.8
Classification:Other Bug Reproducible:Always
 
05-Jul-2012 12:31 AM Wataru Kimura:
Summary:

    On 10.8 Developer Preview, Bignum class of Ruby (/usr/bin/ruby) seems to be broken.

Steps to Reproduce:

    Terminal.app

    $ svn co http://svn.ruby-lang.org/repos/ruby/tags/v1_8_7_358 
    $ cd v1_8_7_358 
    $ ln -s /usr/bin/ruby ./miniruby 
    $ /usr/bin/ruby sample/test.rb | grep not 
    $ /usr/bin/ruby test/ruby/test_bignum.rb

Expected Results:

    pass all tests.

    $ /usr/bin/ruby sample/test.rb | grep not 
    $  /usr/bin/ruby test/ruby/test_bignum.rb
    Loaded suite test/ruby/test_bignum
    Started
    .....
    Finished in 0.00527 seconds.
    
    5 tests, 172 assertions, 0 failures, 0 errors

Actual Results:

    failure some tests of Bignum.

    $ /usr/bin/ruby sample/test.rb | grep not 
    not ok bignum 5 -- sample/test.rb:1279 
    not ok bignum 7 -- sample/test.rb:1281 
    not ok bignum 8 -- sample/test.rb:1282 
    not ok bignum 9 -- sample/test.rb:1284 
    not ok bignum 12 -- sample/test.rb:1292 
    $ /usr/bin/ruby test/ruby/test_bignum.rb- 
    Loaded suite test/ruby/test_bignum 
    Started 
    F.... 
    Finished in 0.008957 seconds. 
 
      1) Failure: 
    test_bignum(TestBignum) [test/ruby/test_bignum.rb:20]: 
    <815915283247897734345611269596115894272000000000> expected but was 
    <12458531232290854317486386476939789467648000000>. 
 
    5 tests, 29 assertions, 1 failures, 0 errors 

Regression:

Notes:

    ruby-1.8 does not support the Clang compiler. 
    I tested ruby-1.8.7 with clang and some configure options.
    only ruby built with CFLAGS="-O0 -std=c89" works fine.
    optimization of llvm/clang will break ruby-1.8.


10-Jul-2012 11:48 PM Wataru Kimura:
I wrote a patch against "numeric.c". this patch solves errors written in this report.

Comments

bad result of Fixnum#**

% uname -r
12.0.0
% /usr/bin/ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
% /usr/bin/ruby /usr/bin/irb
>> 2**62
=> 4611686018427387904
>> 2**63
=> -9223372036854775808
# BAD! right value is 9223372036854775808
>> 2**64
=> 0
# BAD! right value is 18446744073709551616

patch -> https://gist.github.com/3098244


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!