20150714

PaaS and Compiler bugbashing

In the past few days, I thought I should start to have my server code running on some online server, so I decided to give OpenShift a shot - this is a Platform-as-a-Service (PaaS) solution, which - in layman's terms - means I can host my server without paying anything. Of course, the free plan can't handle big traffic, and there are other limitations, too. But it's fine for testing.

Since I wrote my server in Haskell, and OpenShift supports custom cartridges (Haskell, for example), OpenShift was a logical choice. However, it requires that my code is buildable in Cabal (Haskell's "package management" system), which shouldn't be a problem - I just write a .cabal file defining the name of the project, the author, files that are used, etc. Well, it did cause problems.

If I compile my server using `ghc main`, everything works as it should. However, if I use cabal to build it, it doesn't work quite as it should - it hangs at some point. I couldn't uncover the causes, so I wrote a post to reddit (2nd time I ask the internet's help in something), where a commenter gave me some pointers on how I can continue uncovering the secrets of this case. Finally, I was able to find the cause of the problem: cabal has optimization level one on by default. (Cabal invokes GHC with a ton of flags. I took and replicated this command in the comand line, and then tried to delete some flags, trying to figure out which of them causes this problem. Finally I could isolate the -O flag.) No problem, I could simply turn it off in the .cabal file, so the problem is essentially solved. However, there was something still bothering me.

I suspected a bug in the haskell compiler (GHC 7.10.1), so I tried to reproduce the problem with a minimal and complete code. My method was deleting more and more code, furiously recompiling to check if the problem is still there, until there was only one file left, with a code that couldn't be simplified further. I checked a few times more, to be sure that if I made any changes to this code, the problem would go away, and then filed a ticket on GHC's trac.

Since this is my first bugreport, I'm a little nervous, and also I have a feeling I could have done more to help their problem (provided that this actually *is* a compiler bug, and not a result of some silly mistake I made), but we'll see what happens next.

All this was done while I was sleep-deprived and finished a 7-hour shift. It took me about 6 hours to do all this stuff. And I don't have much time to sleep, so I probably should go to sleep now, so I maybe have another 4 hours of sleep. But I think I'll pat myself on the back.

No comments:

Post a Comment