Saturday, 4 April 2009

Another serious bug in GHC

Peter Verswyvelen of Nazooka, one of the only industrial users of Haskell, uncovered another serious bug in GHC, the defacto-standard Haskell compiler. The bug afflicts floating point arithmetic in external libraries such as Qt, GTK, OpenGL, BLAS, LAPACK and FFTW on x86.

Peter said "It's insane this bug did not cause any more problems. Every call into every C function that uses floating point could have been affected". Given that this bug had gone unnoticed for so long, the only logical conclusion is that the GHC FFI is immature because it has very few users. This concurs with our previous findings that no mature software has ever been written in Haskell.

Moreover, this bug joins the list of serious FFI-related bugs in GHC along with the subtle FFI bug in GHC that helped to destroy Darcs and a memory alignment bug in GHC's FFI that caused segmentation faults.

Suffice to say, the moral of this story is that even the most advanced high-level programming language implementations have a real achilles heel when it comes to interoperability with software written in existing unsafe languages like C and C++. This is one of the major issues we are addressing in HLVM through the use of LLVM's mature and well-tested C FFI.


Don Stewart said...

I think this is an amusing bug for you to launch a campaign on, as it affected exactly 1 user, and was fixed weeks before it was even spotted in the wild.

Ziriax said...

Hi Jon.

At Nazooka/Anygma our current products are written in C++ and C#, and we hope our future products will make some use of Haskell or F#.

Personally I like the Haskell community; it answers promptly and fixes bugs fast, so I'm willing to take the bumpy ride and do as much as possible to contribute to make it better, since Haskell has so much to offer. After all it is a research language so I'm not expecting it to be bullet proof yet.

You know, when we wrote software using .NET 1.0, we also lost weeks because of a bug in the interop code, so I guess this is part of the game.

jay paul said...

Excellent post and wonderful blog, I really like this type of interesting articles keep it u.

HP - ENVY TouchSmart Sleekbook 15.6" Touch-Screen Laptop - 6GB Memory - 750GB Hard Drive - Modern Silver

HP - ELITE 15.6" Laptop - 8GB Memory - 180GB Solid State Drive