Java Hangs When Converting 2.2250738585072012e-308
exploringbinary.com
exploringbinary.com
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.
The interesting value here (dValue) is double but the method is without strictfp-qualifier and thus allowed to use not-quite IEEE-754 doubles.
Were the problem at JVM level, I would think that many numeric libraries written in Java would not work either and the problem would've been spotted earlier.
Edit: Thought Markdown syntax for links was in use here.
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.
Imagine your response, but about a kernel privilege escalation bug:
"And yet...in 10+ years...it hasn't been a problem? Certainly the need to fix it but saying it is going to be a "big problem" is a bit theatrical."
Anecdotally, a lot of those [\w+]tube porn sites probably run on a Java server considering the heavy lifting that goes on there.
GET / HTTP/1.0
Accept-Language: en;q=2.2250738585072012e-308
If you're running Tomcat and you call getLocale() on that servlet request, you're toast.
"q" is more properly represented natively as an integer between 0 and 1000.
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)
)