BZ #94: java.lang.Double.valueOf() throws java.lang.IllegalArgumentException: disparate values with OpenJDK on ARM

Status fields:

creation_ts:2008-08-07 13:53
component:jit
version:default branch
rep_platform:arm
op_sys:All
bug_status:RESOLVED
resolution:FIXED
reporter:twisti@complang.tuwien.ac.at
I long thought this bug is somewhere down in OpenJDK's native code, but I'm not sure
anymore.  Here is a stacktrace:

$ java test
Exception in thread "main" java.lang.IllegalArgumentException: disparate values
        at sun.misc.FDBigInt.quoRemIteration(FloatingDecimal.java:2795)
        at sun.misc.FloatingDecimal.dtoa(FloatingDecimal.java:833)
        at sun.misc.FloatingDecimal.<init>(FloatingDecimal.java:460)
        at sun.misc.FloatingDecimal.parseHexString(FloatingDecimal.java:2297)
        at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1064)
        at java.lang.Double.valueOf(Double.java:492)
        at test.main(test.java:43)

Comment #1 by twisti@complang.tuwien.ac.at on 2008-08-07 14:11:23

Somewhere in Double.valueOf() we call this method (this is the first method where
arguments differ):

x86_64:

sun.misc.FpUtils.rawCopySign(DD)D PUBLIC STATIC(1.79769e+308 (0x7fefffffffffffff), 1
(0x3ff0000000000000))

arm:

called: sun.misc.FpUtils.rawCopySign(DD)D PUBLIC STATIC(2.64731e-315
(0x1ff0000000000000), 1 (0x000000003ff00000))

Looks like another byte-swap problem.

Comment #2 by twisti@complang.tuwien.ac.at on 2008-08-07 14:29:21

On an --enable-softfloat ARM build the test is OK:

$ java test
$

The call trace tells us that the values are properly passed:

sun.misc.FpUtils.rawCopySign(DD)D PUBLIC STATIC(1.79769e+308 (0x7fefffffffffffff), 1
(0x3ff0000000000000))

I start to hate FPA on LE ARMs.

Comment #3 by twisti@complang.tuwien.ac.at on 2008-08-07 14:31:38

Btw. sun.misc.FpUtils.rawCopySign() is called from
sun.misc.FloatingDecimal.parseHexString().

Comment #4 by twisti@complang.tuwien.ac.at on 2008-08-07 14:37:01

Created an attachment (id=45)
testcase

Comment #5 by twisti@complang.tuwien.ac.at on 2008-08-07 15:46:17

Xerxes sent me a call trace and it seems we have different problem, although I still
don't know why because he also has a soft-float build.


x86_64:

called: sun.misc.FloatingDecimal.dtoa(IJI)V PRIVATE(0x00000000005f4400 (Class =
"sun.misc.FloatingDecimal"), 1023 (0x000003ff), 9007199254740991 (0x001fffffffffffff),
53 (0x00000035))

called: java.lang.StrictMath.floor(D)D PUBLIC STATIC NATIVE(308.275
(0x4073446485c91398))
finished: java.lang.StrictMath.floor(D)D->308 (0x4073400000000000)


Xerxes' ARM:

called: sun.misc.FloatingDecimal.dtoa(IJI)V PRIVATE(0x00076270 (Class =
"sun.misc.FloatingDecimal"), 1023 (0x000003ff), 9007199254740991 (0x001fffffffffffff),
1144114972 (0x4431cf1c))

called: java.lang.StrictMath.floor(D)D PUBLIC STATIC NATIVE(308.275
(0x4073446485c91398))
finished: java.lang.StrictMath.floor(D)D->1.59098e-314 (0x00000000bff00000)

That looks very much like a native library problem.


Iyonix ARM (hard-float):

called: sun.misc.FloatingDecimal.dtoa(IJI)V PRIVATE(0x0008c2d0 (Class =
"sun.misc.FloatingDecimal"), -1042 (0xfffffbee), 4504059029487616 (0x0010006af6800000),
63104 (0x0000f680))

called: java.lang.StrictMath.floor(D)D PUBLIC STATIC NATIVE(2.71828
(0x800000004005bf0a))
finished: java.lang.StrictMath.floor(D)D->0 (0x0000000000000000)

Comment #6 by xerxes@zafena.se on 2008-08-08 11:22:48

Xerxes' ARM:
Recompiled all native OpenJDK classes and cacao copiled with softfloat passes the
testcase.

xerxes@armel:~/test$ /home/xerxes/cacao-clean/icedtea6/bootstrap/icedtea/bin/java
-version
java version "1.6.0_0"
OpenJDK  Runtime Environment (build 1.6.0_0-b11)
CACAO (build 0.99.2, JIT mode)
xerxes@armel:~/test$ /home/xerxes/cacao-clean/icedtea6/bootstrap/icedtea/bin/javac
test.java
xerxes@armel:~/test$ /home/xerxes/cacao-clean/icedtea6/bootstrap/icedtea/bin/java test
xerxes@armel:~/test$

Comment #7 by stefan@complang.tuwien.ac.at on 2012-04-19 11:43:06

I get

called: sun.misc.FloatingDecimal.dtoa(IJI)V PRIVATE(0x00a524b0 (Class =
"sun.misc.FloatingDecimal"), 1023 (0x000003ff), 9007199254740991 (0x001fffffffffffff), 0
(0x00000000))

called: java.lang.Math.floor(D)D PUBLIC STATIC(308.275 (0x4073446485c91398))
finished: java.lang.Math.floor(D)D->308 (0x4073400000000000)

The last argument of dtoa is wrong, but that seems to be more a problem with
+TraceJavaCalls than with the FP handling itself.

Attachment id=45

date:2008-08-07 14:37
desc:testcase
type:text/x-java
download:test.java