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
version:default branch
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(
        at sun.misc.FloatingDecimal.dtoa(
        at sun.misc.FloatingDecimal.<init>(
        at sun.misc.FloatingDecimal.parseHexString(
        at sun.misc.FloatingDecimal.readJavaFormatString(
        at java.lang.Double.valueOf(
        at test.main(

Comment #1 by on 2008-08-07 14:11:23

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


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


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

Looks like another byte-swap problem.

Comment #2 by 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

I start to hate FPA on LE ARMs.

Comment #3 by on 2008-08-07 14:31:38

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

Comment #4 by on 2008-08-07 14:37:01

Created an attachment (id=45)

Comment #5 by 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.


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
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
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
finished: java.lang.StrictMath.floor(D)D->0 (0x0000000000000000)

Comment #6 by on 2008-08-08 11:22:48

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

xerxes@armel:~/test$ /home/xerxes/cacao-clean/icedtea6/bootstrap/icedtea/bin/java
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
xerxes@armel:~/test$ /home/xerxes/cacao-clean/icedtea6/bootstrap/icedtea/bin/java test

Comment #7 by 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

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