Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compilation hangs for a class with field double d = 2.2250738585072012e-308

I have come across an interesting situation. A coworker committed some changes, which would not compile on my machine neither from the IDE (Eclipse) nor from a command line (Maven). The problem manifested in the compilation process taking 100% CPU and only killing the process would help to stop it. After some analysis the cause of the problem was located and resolved. It turned out be a line "double d = 2.2250738585072012e-308" (without semicolon at the end) in one of the interfaces. The following snipped duplicates it.

public class WeirdCompilationIssue {
   double d = 2.2250738585072012e-308
}

Why would compiler hang? A language edge case?

like image 883
01es Avatar asked Feb 04 '11 08:02

01es


4 Answers

It's a bug in the String-to-double conversion algorithm of the JVM: http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/

You can get the same hang if you try to parse that string at runtime. The compiler hangs because it uses the same code (it's a Java program after all).

Update: the issue now has a CVE identifier (CVE-2010-4476) and a patch (for Oracle JVMs, also works on OpenJDK).

According to the patch it all boils down to an off-by-one error.

like image 187
2 revs Avatar answered Nov 19 '22 19:11

2 revs


This is a known issue which was in news a couple of days back. More info here.

like image 20
Sanjay T. Sharma Avatar answered Nov 19 '22 20:11

Sanjay T. Sharma


This is an open bug for over 10 years. Bad Sun.

The fact that Java systems haven't been attacked and dead in masses proves that there are really very few naughty people on the earth.

like image 3
irreputable Avatar answered Nov 19 '22 20:11

irreputable


Oracle has released a hot fix which can be found here:

http://www.oracle.com/technetwork/java/javase/fpupdater-tool-readme-305936.html

The hotfix will work for java 1.4, 1.5, and 1.6.

like image 1
Tim Funk Avatar answered Nov 19 '22 21:11

Tim Funk