180 points · by pietrofmaggi · 15y ago · 66 comments
I was always afraid that this might bite other environments too as the code that caused the issue in PHP was apparently taken from elsewhere (see http://blog.andreas.org/display?id=9 for a detailed analysis of the problem). Now this is turning out to be true.
Java's turn to deal with the x87 register issue. Here's a hint Oracle, "volatile"
Volatile keyword in Java does not guarantee writing to memory and reading it back (http://java.sun.com/docs/books/jls/third_edition/html/classe...), but using strictfp as a modifier to the method should cause the usage of strict IEEE 64-bit floating point.
PS I am pretty sure Oracle, at least on Sun, used SPARCworks compiler, not GCC, from linking C++ against their libs.
-fexcess-precision=standard
Which apparently defaults to not being standard compliant.This affects JRuby, and potentially anyone with a JSON-based API running on the JVM with a JSON parser using the java stdlib to parse JSON floats:
jruby-1.5.2 > JSON.parse('{"float": 2.2250738585072012e-308}')
^C^C^C^C^C^C
^C^C^C
(not the most recent JRuby I know, but seems this is a JVM problem...)This speaks volumes about Oracle as the Java's steward.
Average over the last 3 issues is about 48 hours - if accepted as a bug. But if you provide source code that demonstrates the problem turnaround is usually very fast, and that seems to be the case here.
This is going to be a big problem.
I expect a lot of teams will have to rush out a patch. I feel for them...
Incidentally, I haven't seen a simple workaround posted anywhere. Has anyone seen a regexp or code snippet that can identify strings which would trigger this bug?
The problem has nothing to do with JSON. It only affects JSON parsers that run on a JVM.
Don't try this in a project you're currently working on. Now I have to spend my morning trying to unfuck my project.
user=> (def d 2.2250738585072012e-308)
Welcome to Scala version 2.8.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22). Type in expressions to have them evaluated. Type :help for more information.
scala> 2.2250738585072012e-308
(infinite loop)
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Oracle JRockit(R) (build R28.0.1-21-133393-1.6.0_20-20100512-2126-linux-ia32, compiled mode)So when a (Java) website expects an Int as input, it's not affected, but Clojure,JRuby etc would be?
Am I right, what am I missing?
(see the comment with
user=> (def d 2.2250738585072012e-308)
)