Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: double to string causes divide by zero!



On Friday, February 27, 2004, at 03:57 PM, Greg Guerin <email@hidden> wrote:

This shouldn't make any difference, as explained above. Nor would
declaring the 'double' as volatile, nor any other Java-language tricks.

The problem exhibited by the original code is not that there's a double or
any other apparent object being shared by two threads. Hence, any attempt
to fix the problem by synchronizing the threads is not addressing the real
problem.

The problem appears to be that something in the JVM/JITC or other
implementation is incorrectly sharing some data between two threads, even
though it shouldn't be. That implies a bug in the JVM or JITC, and since
the bug only appears on a G5, which uses 64-bit opcodes for long division
(see the archives), that's where I'd place my money.

One of our developers has been chasing down an odd bug
on Windows, involving a JNI library he is writing, and
it sheds a little light on what might be happening here.

The problem he has been seeing is that Java floating
point operations can fail after he loaded his native lib.
To quote his email (which I only got about an hour ago!)

The failure is due to corruption of the hardware's floating point control
word (FPCW). The Java implementation requires that all floating point
exceptions (such as overflow, underflow and division by zero) be
disabled. If the FPCW gets changed to enable some of those exceptions,
Java floating point operations can fail. Moreover, they can fail in
surprising places, such as in converting a floating point value to a
String for display. (That one is because the Java conversion code
determines the sign of a value to be converted by dividing it by zero,
since that is one of the few ways to distinguish +0 from -0 when using
IEEE arithmetic.)

He found that loading his lib brought in another DLL
that, as part of its automatically executed on load
initialization code, clobbered the FPCW.
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.