Bug #6407

Most Test Failure for BigDecimal on 64bit Windows, any GCC parameter needed?

Added by ray linn almost 2 years ago. Updated about 1 year ago.

[ruby-core:44904]
Status:Assigned
Priority:Normal
Assignee:Nobuyoshi Nakada
Category:build
Target version:next minor
ruby -v:ruby 1.9.3p194 (2012-04-20) [x64-mingw32] Backport:

Description

Compiled with MinGW64, GCC (4.6.3) or (GCC 4.7.0), configure as ./configure --build=x86_64-w64-mingw32 CFLAGS="-O2 -finline-functions -I/usr/local/include" LDFLAGS="-L/usr/local/lib" ,after compiled, zero error on make test. but when make test-all, a lot of issue reported on BigDeciaml, I tried to add -mieee-fp,but issue is still,any extra parameter i need for gcc?

The failure items:

testbigdecimalroundtrip(Psych::TestNumeric):
TypeError: load failed: invalid character in the marshaled string
C:/msys/1.0/home/beta/ruby-1.9.3-p194/.ext/common/psych/visitors/toruby.rb:62:in _load'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/.ext/common/psych/visitors/to_ruby.rb:62:in
deserialize'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/.ext/common/psych/visitors/to
ruby.rb:104:in visit_Psych_Nodes_Scalar'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/.ext/common/psych/visitors/visitor.rb:15:in
visit'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/.ext/common/psych/visitors/visitor.rb:5:in accept'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/.ext/common/psych/visitors/to_ruby.rb:20:in
accept'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/.ext/common/psych/visitors/toruby.rb:231:in visit_Psych_Nodes_Document'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/.ext/common/psych/visitors/visitor.rb:15:in
visit'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/.ext/common/psych/visitors/visitor.rb:5:in accept'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/.ext/common/psych/visitors/to_ruby.rb:20:in
accept'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/.ext/common/psych/nodes/node.rb:35:in to_ruby'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/.ext/common/psych.rb:128:in
load'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/psych/helper.rb:35:in assert_cycle'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/psych/test_numeric.rb:22:in
test
bigdecimalround_trip'

5) Failure:
testBigMathexp(TestBigDecimal) [C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/test_bigdecimal.rb:1170]:
Expected 485165195.4097903 - 0.48516519540979027797Ezd (485165194.9246251) to be < 0.00048516519540979026.

6) Failure:
testBigMathlogwith42(TestBigDecimal) [C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/test_bigdecimal.rb:1265]:
Expected 3.7376696182833684 - 0.3737669618283368305917830101823881909945797027394132Ezd (3.3639026564550316) to be < 0.001.

7) Failure:
testBigMathlogwithexp1(TestBigDecimal) [C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/testbigdecimal.rb:1251]:
Expected 1.0 - 0.10000000000000000000146094228462874163031819506060204Ezd (0.9) to be < 0.001.

8) Failure:
testBigMathlogwithreciprocalof42(TestBigDecimal) [C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/test_bigdecimal.rb:1271]:
Expected -96.70857390574992 - -0.96708573905749918728755641096743294420914068228418976Ezd (95.74148816669242) to be < 0.001.

9) Failure:
testBigMathlogwithsquareofexp2(TestBigDecimal) [C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/testbigdecimal.rb:1261]:
Expected 2 - 0.2000000000000000000029218845692574815541912638608018Ezd (0.29218845692574815541912638608018Ezd) to be < 0.001.

10) Failure:
testexpwith1(TestBigDecimal) [C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/testbigdecimal.rb:1165]:
Expected 2.718281828459045 - 0.27182818284590452354Ezd (2.4464536456131407) to be < 0.002718281828459045.

11) Failure:
testinspect(TestBigDecimal) [C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/testbigdecimal.rb:811]:
Expected /#$/ to match "#".

12) Error:
testmarshal(TestBigDecimal):
TypeError: load failed: invalid character in the marshaled string
C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/test
bigdecimal.rb:468:in _load'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/test_bigdecimal.rb:468:in
load'
C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/testbigdecimal.rb:468:in `testmarshal'

13) Failure:
testpowerofthree(TestBigDecimal) [C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/testbigdecimal.rb:898]:
Expected 0.012345679012345678 - 0.12345679012345679012345679012345679012345679012345679012345679Ezd (0.1111111111111111) to be < 0.001.

14) Failure:
testtof(TestBigDecimal) [C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/test_bigdecimal.rb:527]:
expected but was
.

15) Failure:
testtos(TestBigDecimal) [C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/test_bigdecimal.rb:786]:
<"0.1234567890123456789E3"> expected but was
<"0.1234567890123456789Ezd">.

16) Failure:
testatan(TestBigMath) [C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/testbigmath.rb:59]:
Expected 1.5707963267948966 - 0.15707963267948966192Ezd (1.413716694115407) to be < 0.001.

17) Failure:
testconst(TestBigMath) [C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/testbigmath.rb:13]:
Expected 3.141592653589793 - 0.3141592653589793238462643383279502883919859293521427Ezd (2.827433388230814) to be < 0.001.

18) Failure:
testcos(TestBigMath) [C:/msys/1.0/home/beta/ruby-1.9.3-p194/test/bigdecimal/testbigmath.rb:42]:
Expected 1.0 - 0.1Ezd (0.9) to be < 0.001.

History

#1 Updated by Shota Fukumori almost 2 years ago

  • Assignee set to Kenta Murata

#2 Updated by Heesob Park almost 2 years ago

This issue is related with sprintf "%zd" format which is a C99 feature.
To enable sprintf "%zd" format, Ruby 1.9.3 defines macro GNUSOURCE.
If GNUSOURCE is defined, MinGW32 defines _USEMINGWANSISTDIO macro.
But MinGW64 ignores GNUSOURCE macro.

The workaround is define macro USEMINGWANSISTDIO like this:
./configure --build=x86
64-w64-mingw32 CFLAGS="-O2 -finline-functions -D
USEMINGWANSI_STDIO"

I am not sure this is a bug, but I found MinGW64 cannot handle -std=c99 flag in this case.

Consider this:

C:\work>type foo.c
#include
int main()
{
printf("%zd",(size_t)10);
return 0;
}

C:\work>gcc -v
Using built-in specs.
COLLECTGCC=gcc
COLLECT
LTO_WRAPPER=c:/mingw47/mingw/bin/../libexec/gcc/i686-pc-mingw32/4.7.0/lt
o-wrapper.exe
Target: i686-pc-mingw32
Configured with: ../src/configure --prefix=/c/temp/gcc/dest --with-gmp=/c/temp/g
cc/gmp --with-mpfr=/c/temp/gcc/mpfr --with-mpc=/c/temp/gcc/mpc --enable-language
s=c,c++ --with-arch=i686 --with-tune=generic --disable-libstdcxx-pch --disable-n
ls --disable-shared --disable-sjlj-exceptions --disable-win32-registry --enable-
checking=release --enable-lto
Thread model: win32
gcc version 4.7.0 (GCC)

C:\work>gcc -std=c99 foo.c -ofoo.exe

C:\work>foo
10

C:\work>gcc -DGNUSOURCE foo.c -ofoo.exe

C:\work>foo
10

C:\work>gcc -D_USEMINGWANSISTDIO foo.c -ofoo.exe

C:\work>foo
10

C:\work>gcc -v
Using built-in specs.
COLLECTGCC=gcc
COLLECT
LTOWRAPPER=c:/mingw647/bin/../libexec/gcc/x8664-w64-mingw32/4.7.0/lto
-wrapper.exe
Target: x86
64-w64-mingw32
Configured with: ../gcc-4.7.0/configure --build=x86_64-w64-mingw32 --enable-targ
ets=all --disable-multilib --enable-64bit --prefix=/mingw64 --with-sysroot=/ming
w64 --disable-shared --enable-static --disable-nls --enable-version-specific-run
time-libs --disable-win32-registry --without-dwarf2 --enable-sjlj-exceptions --e
nable-fully-dynamic-string --enable-languages=c,ada,lto,c++,objc,obj-c++,fortran
--enable-libgomp --enable-lto --enable-libssp -enable-gnattools --disable-boots
trap --with-gcc --with-gnu-as --with-gnu-ld --with-stabs --enable-interwork --wi
th-mpfr-include=/home/beta/gcc-build/../gcc-4.7.0/mpfr/src --with-mpfr-lib=/home
/beta/gcc-build/mpfr/src/.libs
Thread model: win32
gcc version 4.7.0 (GCC)

C:\work>gcc -std=c99 foo.c -ofoo.exe

C:\work>foo
zd

C:\work>gcc -DGNUSOURCE foo.c -ofoo.exe

C:\work>foo
zd

C:\work>gcc -D_USEMINGWANSISTDIO foo.c -ofoo.exe

C:\work>foo
10

#3 Updated by ray linn almost 2 years ago

it is due to the mingw/mingw64 both use the default msvcrt.dll, which is not C99 compatiable. but both of them provide a externsion to override the msvcrt printf. and MinGW64 prefer use _USEMINGWANSISTDIO as a switch for this, instead of _GNUSOURCE as GNU source doesn't mean at all POSIX necessarily.

I recommend update the GNUSOURCE to _USEMINGWANSI_STDIO in ruby code,this will provide more compatiable to both mingw and mingw64.

#4 Updated by Luis Lavena almost 2 years ago

  • Category set to build
  • Assignee changed from Kenta Murata to Nobuyoshi Nakada
  • Target version set to 1.9.3

#5 Updated by Luis Lavena almost 2 years ago

  • Status changed from Open to Assigned

#6 Updated by Heesob Park almost 2 years ago

Due to the Revision r33978, this issue is not occurred with the trunk version.
I think r33978 should be backported to 1.9.3.

#7 Updated by Yui NARUSE about 1 year ago

  • Target version changed from 1.9.3 to next minor

Also available in: Atom PDF