Why does this work in a program, but cause a seg fault in ghci?

Hi, I am going through the OpenGL tutorial 1 (http://www.haskell.org/haskellwiki/OpenGLTutorial1) The first example program in chapter 2 works if I compile it and run it, but I don't understand all of it so I am playing with bits of it in ghci. Look what happens: GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> let myPoints = map (\k -> (sin(2*pi*k/12),cos(2*pi*k/12),0.0)) [1..12] Prelude> myPoints [(0.49999999999999994,0.8660254037844387,0.0),(0.8660254037844386,0.5000000000000001,0.0),(1.0,6.123233995736766e-17,0.0),(0.8660254037844388,-Segmentation fault Any ideas? Thanks

AFAIK, that should never happen. The expression looks sane, too, so I
guess it's a bug in GHCi. 6.10.4 is not the latest stable version of
GHC, so you might want to update it.
On Tue, Aug 10, 2010 at 11:51 PM, Kurt Häusler
Hi, I am going through the OpenGL tutorial 1 (http://www.haskell.org/haskellwiki/OpenGLTutorial1)
The first example program in chapter 2 works if I compile it and run it, but I don't understand all of it so I am playing with bits of it in ghci. Look what happens:
GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> let myPoints = map (\k -> (sin(2*pi*k/12),cos(2*pi*k/12),0.0)) [1..12] Prelude> myPoints [(0.49999999999999994,0.8660254037844387,0.0),(0.8660254037844386,0.5000000000000001,0.0),(1.0,6.123233995736766e-17,0.0),(0.8660254037844388,-Segmentation fault
Any ideas?
Thanks_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners

Am 11.08.2010 04:51 schrieb Kurt Häusler:
Hi, I am going through the OpenGL tutorial 1 (http://www.haskell.org/haskellwiki/OpenGLTutorial1)
The first example program in chapter 2 works if I compile it and run it, but I don't understand all of it so I am playing with bits of it in ghci. Look what happens:
GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> let myPoints = map (\k -> (sin(2*pi*k/12),cos(2*pi*k/12),0.0)) [1..12] Prelude> myPoints [(0.49999999999999994,0.8660254037844387,0.0),(0.8660254037844386,0.5000000000000001,0.0),(1.0,6.123233995736766e-17,0.0),(0.8660254037844388,-Segmentation fault
Any ideas?
Thanks_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
Hi Kurt, I tested it with GHCi 6.10.4 on a Windows XP system and it works fine: GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> let myPoints = map (\k -> (sin(2*pi*k/12),cos(2*pi*k/12),0.0)) [1..12] Prelude> myPoints [(0.49999999999999994,0.8660254037844387,0.0),(0.8660254037844386,0.5000000000000001,0.0), (1.0,6.123031769111886e-17,0.0),(0.8660254037844387,-0.4999999999999998,0.0), (0.49999999999999994,-0.8660254037844387,0.0),(1.2246063538223773e-16,-1.0,0.0), (-0.4999999999999997,-0.8660254037844388,0.0),(-0.8660254037844384,-0.5000000000000004,0.0), (-1.0,-1.836909530733566e-16,0.0),(-0.8660254037844386,0.5000000000000001,0.0), (-0.5000000000000004,0.8660254037844384,0.0),(-2.4492127076447545e-16,1.0,0.0)] What system are you on? Best wishes, Maciej

On Wed, Aug 11, 2010 at 5:56 AM, Maciej Podgurski
What system are you on?
It was a mixture of an old darwin port of 6.10.4 that I had forgotten about, and came first in my path, and the second most recent Haskell platform on Mac OS. I deleted the darwin port, and updated the Haskell platform and now it works as expected. I am a bit worried there might be a few nasty surprises hiding in my .cabal though, but there doesn't seem to be a command to force a recompilation of everything installed by cabal so for now I will assume it is not necessary.

On Wednesday 11 August 2010 08:46:27, Kurt Häusler wrote:
On Wed, Aug 11, 2010 at 5:56 AM, Maciej Podgurski
wrote: What system are you on?
It was a mixture of an old darwin port of 6.10.4 that I had forgotten about, and came first in my path, and the second most recent Haskell platform on Mac OS.
I deleted the darwin port, and updated the Haskell platform and now it works as expected.
I am a bit worried there might be a few nasty surprises hiding in my .cabal though, but there doesn't seem to be a command to force a recompilation of everything installed by cabal so for now I will assume it is not necessary.
ghc-pkg check should tell you about broken packages. Anything it reports as broken, you should reinstall. When ghc-pkg check reports no breakages, you can assume everything works (no guarantees, though).
participants (4)
-
Daniel Fischer
-
Kurt Häusler
-
Maciej Podgurski
-
Sebastián E. Peyrott