GHC 6.7 on Windows / containers-0.1 package?

Since I'm hopelessly stuck with an weird infinite loop (that consumes 0% CPU time!), and since I can't find the problem using "trace", I wanted to try GHC 6.7, which seems to container a debugger (woohoo!!!). Currently I'm using GHC-6.6.1 on Windows. So I grabbed ghc-6.7.20070824 (=the latest one for Windows I could find) and the "extra-libs", compiled and installed the GLUT package (which I needed), but when I compile my library, I get Could not find module `Data.Map': it is a member of package containers-0.1, which is hidden So I tried to expose it using GHC-PKG expose containers-0.1 which worked find, because GHC-PKG list prints d:/app/ghc/ghc-6.7.20070824\package.conf: Cabal-1.1.7, GLUT-2.1.1, HUnit-1.1.1, OpenGL-2.2.1, QuickCheck-1.0.1, Win32-2.1, array-0.1, arrows-0.2.1, base-2.1, bytestring-0.1, cgi-3001.1.5, containers-0.1, directory-1.0, fgl-5.4.1, filepath-1.0, (ghc-6.7.20070824), haskell-src-1.0.1, haskell98-1.0, hpc-0.5, html-1.0.1, mtl-1.0.1, network-2.0.1, old-locale-1.0, old-time-1.0, packedstring-0.1, parallel-1.0, parsec-2.0, pretty-1.0, process-1.0, random-1.0, regex-base-0.72, rts-1.0, stm-2.1, template-haskell-0.1, xhtml-3000.0.2 Anybody has an idea how I can continue? Thanks (again!), Peter

Hi Peter,
So I grabbed ghc-6.7.20070824 (=the latest one for Windows I could find) and the "extra-libs", compiled and installed the GLUT package (which I needed), but when I compile my library, I get
Could not find module `Data.Map': it is a member of package containers-0.1, which is hidden
All dependencies etc. have changed when going to 6.7/6.8 - you are probably better off using 6.6.1 for now. I also don't think that the debugger will help you track down infinite loop style errors. You might be better off posting the code and asking for help. Thanks Neil

On Wed, Sep 19, 2007 at 10:24:24PM +0100, Neil Mitchell wrote:
Hi Peter,
So I grabbed ghc-6.7.20070824 (=the latest one for Windows I could find) and the "extra-libs", compiled and installed the GLUT package (which I needed), but when I compile my library, I get
Could not find module `Data.Map': it is a member of package containers-0.1, which is hidden
All dependencies etc. have changed when going to 6.7/6.8 - you are probably better off using 6.6.1 for now.
I also don't think that the debugger will help you track down infinite loop style errors. You might be better off posting the code and asking for help.
You said 0% CPU. That's *very* important. It means that you are using the threaded runtime (GHCi?), and that you triggered a blackhole. You should be able to handle this by compiling your program with -prof (do *not* use -threaded!), and running with +RTS -xc. With luck, that will give you a backtrace to the infinite loop. PS. blackholes are a serious dark corner of GHC's execution model, chances are better than even that if you try to use the debugger for this you will discover a new and (for you) crippling bug. I wouldn't recommend it. Stefan

Stefan O'Rear wrote:
You said 0% CPU. That's *very* important. It means that you are using the threaded runtime (GHCi?), and that you triggered a blackhole. You should be able to handle this by compiling your program with -prof (do *not* use -threaded!), and running with +RTS -xc. With luck, that will give you a backtrace to the infinite loop.
PS. blackholes are a serious dark corner of GHC's execution model, chances are better than even that if you try to use the debugger for this you will discover a new and (for you) crippling bug. I wouldn't recommend it.
Hi Stefan, I do not understand. Do you mean you would not recommend to try the debugger to check this problem? I had something which looked similar but the problem was that my gui (gkt2hs) application is also printing to console and there was an active selection in the console, so the printing was suspended :-) Peter.

Thanks for the info, very interesting. Yes, I'm using GHCi, and I'm using forkOS, and I'm using OpenGL... Since I'm used to write heavily multi-threaded/multi-core code in imperative languages, I would like to understand more about the existing execution models, and those "black holes"... Understanding the low-level details helps a lot for me. Actually the problem was caused by (yet another) strict pattern match in my code, which should have been lazy. I find it strange that this would cause 0% CPU time... But then again I don't understand the details of how GHCi/GHC works. I did read the book "Modern Compiler Design" (http://www.cs.vu.nl/~dick/MCD.html) which implements a basic Haskell interpreter & compiler, so I got an introduction. Anyway, it's a very good learning experience for me to "redo" FRP from scratch, as I encounter all pitfalls (such as the need for memoization when using recursive streams, the need for lazy pattern matching, the space leaks sneaking up on you, etc). Once I get to understand these in detail, I'll try to re-read the existing papers on FRP, which I hardly understood initially :-) Thanks, Peter Stefan O'Rear wrote:
On Wed, Sep 19, 2007 at 10:24:24PM +0100, Neil Mitchell wrote:
Hi Peter,
So I grabbed ghc-6.7.20070824 (=the latest one for Windows I could find) and the "extra-libs", compiled and installed the GLUT package (which I needed), but when I compile my library, I get
Could not find module `Data.Map': it is a member of package containers-0.1, which is hidden
All dependencies etc. have changed when going to 6.7/6.8 - you are probably better off using 6.6.1 for now.
I also don't think that the debugger will help you track down infinite loop style errors. You might be better off posting the code and asking for help.
You said 0% CPU. That's *very* important. It means that you are using the threaded runtime (GHCi?), and that you triggered a blackhole. You should be able to handle this by compiling your program with -prof (do *not* use -threaded!), and running with +RTS -xc. With luck, that will give you a backtrace to the infinite loop.
PS. blackholes are a serious dark corner of GHC's execution model, chances are better than even that if you try to use the debugger for this you will discover a new and (for you) crippling bug. I wouldn't recommend it.
Stefan

On 9/21/07, Peter Verswyvelen
Since I'm used to write heavily multi-threaded/multi-core code in imperative languages, I would like to understand more about the existing execution models, and those "black holes"... Understanding the low-level details helps a lot for me.
I think you want to know about the STG, the Spineless Tagless G-Machine. If I'm correct, that's how GHC works behind the scenes. -- Felipe.

On Fri, Sep 21, 2007 at 05:40:59PM -0300, Felipe Almeida Lessa wrote:
On 9/21/07, Peter Verswyvelen
wrote: Since I'm used to write heavily multi-threaded/multi-core code in imperative languages, I would like to understand more about the existing execution models, and those "black holes"... Understanding the low-level details helps a lot for me.
I think you want to know about the STG, the Spineless Tagless G-Machine. If I'm correct, that's how GHC works behind the scenes.
STG is a very pretty island, but it's just that - an island. If you want to see the Big Picture, I can only recommend SPJ's 1987 (except for the optimization section, almost everything is still true) book: http://research.microsoft.com/~simonpj/papers/slpj-book-1987/slpj-book-1987.... Stefan

STG is a very pretty island, but it's just that - an island. If you want to see the Big Picture, I can only recommend SPJ's 1987 (except for the optimization section, almost everything is still true) book:
http://research.microsoft.com/~simonpj/papers/slpj-book-1987/slpj-book-1987....
Stefan
Well, if the sun shines on that island, I wouldn't mind spending a holiday over there ;-) 1987??? Gee, I was still programming in 6502 & 68000 assembler then :-) Of course, I guess one could not use Haskell back then to make a videogame on home computers with 64KB of RAM ;-) Is this still up-to-date with the way GHC/GHCi work internally? Then I'll certainly check it out. Thanks, Peter

Hello Peter, Saturday, September 22, 2007, 1:41:44 AM, you wrote:
Is this still up-to-date with the way GHC/GHCi work internally? Then I'll certainly check it out.
you should look at SPJ papers' page. it contains section with ghc-implementation details. just a few papers from there, sorted by publication time: Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine. [http://research.microsoft.com/copyright/accept.asp?path=/users/simonpj/paper...] [http://www.haskell.org/ghc/docs/papers/run-time-system.ps.gz] Making a fast curry: push/enter vs. eval/apply for higher-order languages [http://www.haskell.org/~simonmar/papers/eval-apply.pdf] -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Stefan O'Rear wrote:
On Wed, Sep 19, 2007 at 10:24:24PM +0100, Neil Mitchell wrote:
Hi Peter,
So I grabbed ghc-6.7.20070824 (=the latest one for Windows I could find) and the "extra-libs", compiled and installed the GLUT package (which I needed), but when I compile my library, I get
Could not find module `Data.Map': it is a member of package containers-0.1, which is hidden All dependencies etc. have changed when going to 6.7/6.8 - you are probably better off using 6.6.1 for now.
I also don't think that the debugger will help you track down infinite loop style errors. You might be better off posting the code and asking for help.
You said 0% CPU. That's *very* important. It means that you are using the threaded runtime (GHCi?), and that you triggered a blackhole. You should be able to handle this by compiling your program with -prof (do *not* use -threaded!), and running with +RTS -xc. With luck, that will give you a backtrace to the infinite loop.
As Stefan said, when the program hangs using 0% CPU, it probably means you have a "black hole". A black hole is a particular kind of infinite loop; one that GHC detects. In this case it has detected that the program is in a loop, but it hasn't managed to detect that the loop is a real deadlock - if it did, then you'd also get an exception ("<<loop>>"). The failure to deliver an exception happens in GHCi for subtle reasons that I've forgotten, it might even behave differently in GHC 6.8.1. The debugger in 6.8.1 can also help to track down loops and deadlocks. Set -fbreak-on-error, run the program using :trace, and hit Control-C when it hangs. Then :history will give you a list of the most recently-visited points in your program, so you can step back and inspect the values of variables. Cheers, Simon

Super, really looking forward to GHC 6.8.1 then. Is it ready for primetime on Windows? Again, someone should really build an IDE around all these goodies, but yes, that is a massive undertaking. Cheers, Peter
The debugger in 6.8.1 can also help to track down loops and deadlocks. Set -fbreak-on-error, run the program using :trace, and hit Control-C when it hangs. Then :history will give you a list of the most recently-visited points in your program, so you can step back and inspect the values of variables.
Cheers, Simon
participants (7)
-
Bulat Ziganshin
-
Felipe Almeida Lessa
-
Neil Mitchell
-
Peter Hercek
-
Peter Verswyvelen
-
Simon Marlow
-
Stefan O'Rear