Live data from Hacker News

Java Hangs When Converting 2.2250738585072012e-308

exploringbinary.com

21–30 of 70 posts

Re: Java Hangs When Converting 2.2250738585072012e-308

#22
post #6

I have a feeling we will see this come up in more places. When we fixed the code for PHP we saw very similar code in a lot of other projects.

Yes, every project should check its strtod function. If it has a potentially infinite loop, be very worried :)

Re: Java Hangs When Converting 2.2250738585072012e-308

#23
Ouch.

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...)

Re: Java Hangs When Converting 2.2250738585072012e-308

#25
post #24
post #7

Earlier quoted context omitted.

Just to confirm .NET/C# handles this and correctly. So does IronScheme.

Why would a Java / JVM issue hang the .NET CLR?

Because by all accounts this isn't a Java/JVM issue. It's a flaw in a commonly used algorithm for handling floating point numbers. Given that php and possibly gcc use variations on the same algorithm, and have the same flaw, it's not unreasonable to think that other languages/compilers/runtimes would also be affected.

Re: Java Hangs When Converting 2.2250738585072012e-308

#26
post #24
post #7

Earlier quoted context omitted.

Just to confirm .NET/C# handles this and correctly. So does IronScheme.

Why would a Java / JVM issue hang the .NET CLR?

I guess because only a couple of weeks ago a similar issue has surfaced in PHP so it is not entirely unreasonable to check whether other runtimes have similar problems?

Re: Java Hangs When Converting 2.2250738585072012e-308

#27
post #24
post #7

Earlier quoted context omitted.

Just to confirm .NET/C# handles this and correctly. So does IronScheme.

Why would a Java / JVM issue hang the .NET CLR?

As the article "The PHP strtod() denial of service bug" (http://blog.andreas.org/display?id=9 ; linked by pilif in another comment) states, it looks like the code for the conversion is used in a few prominent libraries (e.g. Apple's libc, Android libc, GCC libio etc.). Therefore, it could've been quite possible that the mentioned code has been adopted by Microsoft, too; leppie just confirmed that everything works fine over there.

Re: Java Hangs When Converting 2.2250738585072012e-308

#28
post #25
post #24

Earlier quoted context omitted.

Why would a Java / JVM issue hang the .NET CLR?

Because by all accounts this isn't a Java/JVM issue. It's a flaw in a commonly used algorithm for handling floating point numbers. Given that php and possibly gcc use variations on the same algorithm, and have the same flaw, it's not unreasonable to think that other languages/compilers/runtimes would also be affected.

Thanks for the clarification.

Re: Java Hangs When Converting 2.2250738585072012e-308

#29
post #24
post #7

Earlier quoted context omitted.

Just to confirm .NET/C# handles this and correctly. So does IronScheme.

Why would a Java / JVM issue hang the .NET CLR?

You obviously did not read the Moonlight vs IcedTea issue in Chrome article yesterday ;)
Post reply on HN