Opened 4 years ago

Closed 3 years ago

#5405 closed bug (worksforme)

Strange closure type crash when using Template Haskell on OS X Lion

Reported by: AndreasVoellmy Owned by:
Priority: normal Milestone: 7.6.1
Component: GHCi Version: 7.0.4
Keywords: Cc: andreas.voellmy@…
Operating System: MacOS X Architecture: x86_64 (amd64)
Type of failure: GHCi crash Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

GHCI crashes when I try to use Template Haskell on OS X Lion. To illustrate this, I have a small module, in a file A.hs:

module A where

import Language.Haskell.TH (Exp)
import Language.Haskell.SyntaxTrees.ExtsToTH (parseToTH) 

transform :: String -> Either String Exp
transform = parseToTH

ex1 = "42"

When I start ghci, load A, and evaluate ex1, and wait a couple seconds I get a crash, that usually reports something like this:

*A> ghc: internal error: evacuate: strange closure type 0
    (GHC version 7.0.4 for x86_64_apple_darwin)
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
Abort trap: 6

Sometimes I get different crash messages as well, such as:

*A> Segmentation fault: 11

Here is the transcript of a ghci session:

Andreas$ ghci -v
GHCi, version 7.0.4: http://www.haskell.org/ghc/  :? for help
Glasgow Haskell Compiler, Version 7.0.4, for Haskell 98, stage 2 booted by GHC version 7.0.2
Using binary package database: /Library/Frameworks/GHC.framework/Versions/7.0.4-x86_64/usr/lib/ghc-7.0.4/package.conf.d/package.cache
Using binary package database: /Users/Andreas/.ghc/x86_64-darwin-7.0.4/package.conf.d/package.cache
wired-in package ghc-prim mapped to ghc-prim-0.2.0.0-d9df11f804556f362beb0ea4e67261ba
wired-in package integer-gmp mapped to integer-gmp-0.2.0.3-298c59ba68b7aaa7e76ae5b1fe5e876e
wired-in package base mapped to base-4.3.1.0-239d76b73f466dc120129098b3472858
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.5.0.0-b46cde34bfee890dc536d5be377e906f
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags: -static
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> :l A
*** Chasing dependencies:
Chasing modules from: 
Stable obj: []
Stable BCO: []
unload: retaining objs []
unload: retaining bcos []
Ready for upsweep []
Upsweep completely successful.
*** Deleting temp files:
Deleting: 
*** Chasing dependencies:
Chasing modules from: *A.hs
Stable obj: []
Stable BCO: []
unload: retaining objs []
unload: retaining bcos []
Ready for upsweep
  [NONREC
      ModSummary {
         ms_hs_date = Wed Aug 10 16:52:58 EDT 2011
         ms_mod = main:A,
         ms_imps = [import Prelude,
                    import Language.Haskell.SyntaxTrees.ExtsToTH ( parseToTH ),
                    import Language.Haskell.TH ( Exp )]
         ms_srcimps = []
      }]
compile: input file A.hs
*** Checking old interface for main:A:
[1 of 1] Compiling A                ( A.hs, interpreted )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
    Result size = 13
*** Simplifier SimplMode {Phase = 0 [final],
                      inline,
                      no rules,
                      eta-expand,
                      case-of-case} max-iterations=4:
    Result size = 13
*** Tidy Core:
    Result size = 13
*** CorePrep:
    Result size = 13
*** ByteCodeGen:
*** Deleting temp files:
Deleting: 
Upsweep completely successful.
*** Deleting temp files:
Deleting: 
Ok, modules loaded: A.
wired-in package ghc-prim mapped to ghc-prim-0.2.0.0-d9df11f804556f362beb0ea4e67261ba
wired-in package integer-gmp mapped to integer-gmp-0.2.0.3-298c59ba68b7aaa7e76ae5b1fe5e876e
wired-in package base mapped to base-4.3.1.0-239d76b73f466dc120129098b3472858
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.5.0.0-b46cde34bfee890dc536d5be377e906f
wired-in package dph-seq not found.
wired-in package dph-par not found.
wired-in package ghc-prim mapped to ghc-prim-0.2.0.0-d9df11f804556f362beb0ea4e67261ba
wired-in package integer-gmp mapped to integer-gmp-0.2.0.3-298c59ba68b7aaa7e76ae5b1fe5e876e
wired-in package base mapped to base-4.3.1.0-239d76b73f466dc120129098b3472858
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.5.0.0-b46cde34bfee890dc536d5be377e906f
wired-in package dph-seq not found.
wired-in package dph-par not found.
*A> ex1
wired-in package ghc-prim mapped to ghc-prim-0.2.0.0-d9df11f804556f362beb0ea4e67261ba
wired-in package integer-gmp mapped to integer-gmp-0.2.0.3-298c59ba68b7aaa7e76ae5b1fe5e876e
wired-in package base mapped to base-4.3.1.0-239d76b73f466dc120129098b3472858
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.5.0.0-b46cde34bfee890dc536d5be377e906f
wired-in package dph-seq not found.
wired-in package dph-par not found.
*** Parser:
*** Desugar:
*** Simplify:
*** CorePrep:
*** ByteCodeGen:
Loading package array-0.3.0.2 ... linking ... done.
Loading package bytestring-0.9.1.10 ... linking ... done.
Loading package containers-0.4.0.0 ... linking ... done.
Loading package ghc-binary-0.5.0.2 ... linking ... done.
Loading package filepath-1.2.0.0 ... linking ... done.
Loading package old-locale-1.0.0.2 ... linking ... done.
Loading package old-time-1.0.0.6 ... linking ... done.
Loading package unix-2.4.2.0 ... linking ... done.
Loading package directory-1.1.0.0 ... linking ... done.
Loading package pretty-1.0.1.2 ... linking ... done.
Loading package process-1.0.1.5 ... linking ... done.
Loading package Cabal-1.10.2.0 ... linking ... done.
Loading package bin-package-db-0.0.0.0 ... linking ... done.
Loading package hpc-0.5.0.6 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package ghc-7.0.4 ... linking ... done.
Loading package extensible-exceptions-0.1.1.2 ... linking ... done.
Loading package time-1.2.0.3 ... linking ... done.
Loading package random-1.0.0.3 ... linking ... done.
Loading package cpphs-1.12 ... linking ... done.
Loading package haskell-src-exts-1.11.1 ... linking ... done.
Loading package transformers-0.2.2.0 ... linking ... done.
Loading package mtl-2.0.1.0 ... linking ... done.
Loading package MonadCatchIO-mtl-0.3.0.3 ... linking ... done.
Loading package ghc-mtl-1.0.1.0 ... linking ... done.
Loading package ghc-paths-0.1.0.8 ... linking ... done.
Loading package haskell98-1.1.0.1 ... linking ... done.
Loading package syb-0.3.3 ... linking ... done.
Loading package haskell-src-1.0.1.4 ... linking ... done.
Loading package utf8-string-0.3.6 ... linking ... done.
Loading package hint-0.3.3.2 ... linking ... done.
Loading package uniplate-1.6 ... linking ... done.
Loading package syntax-trees-0.1.2 ... linking ... done.
"42"
wired-in package ghc-prim mapped to ghc-prim-0.2.0.0-d9df11f804556f362beb0ea4e67261ba
wired-in package integer-gmp mapped to integer-gmp-0.2.0.3-298c59ba68b7aaa7e76ae5b1fe5e876e
wired-in package base mapped to base-4.3.1.0-239d76b73f466dc120129098b3472858
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.5.0.0-b46cde34bfee890dc536d5be377e906f
wired-in package dph-seq not found.
wired-in package dph-par not found.
*A> ghc: internal error: evacuate: strange closure type 0
    (GHC version 7.0.4 for x86_64_apple_darwin)
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
Abort trap: 6

Some more details about my setup:

My machine:

Darwin 11.0.0 Darwin Kernel Version 11.0.0: Sat Jun 18 12:56:35 PDT 2011; root:xnu-1699.22.73~1/RELEASE_X86_64 x86_64

gcc -v:

Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2335.15~25/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2335.15~25/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)

Change History (9)

comment:1 Changed 4 years ago by AndreasVoellmy

  • Cc andreas.voellmy@… added

comment:2 Changed 4 years ago by chak

Andreas,

Thank you for the report. Could you check whether that problem is still present in the just released version 7.2.1 of GHC?

Manuel

comment:3 Changed 4 years ago by AndreasVoellmy

I tried to reproduce with 7.2.1, but am stuck sorting out dependencies. I need both haskell-src-exts and syntax-trees packages installed, but installing syntax-trees fails with the following problem:

$ cabal install syntax-trees
Resolving dependencies...
cabal: dependencies conflict: ghc-7.2.1 requires unix ==2.5.0.0 however
unix-2.5.0.0 was excluded because hint-0.3.3.2 requires unix >=2.2.0.0 && <2.5

I've gotten the hint package and updated the dependencies to allow unix<=2.5.0.0, but installing hint with this updated hint.cabal file then gives the following error:

/usr/bin/ghc --make -package-name haskell-src-1.0.1.4 -hide-all-packages -fbuilding-cabal-package -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build -optP-include -optPdist/build/autogen/cabal_macros.h -odir dist/build -hidir dist/build -stubdir dist/build -package-id array-0.3.0.3-c44933d3fbce723d80826d5476f34587 -package-id base-4.4.0.0-b81f1ae0118e4c9367b9db3fd76eea62 -package-id haskell98-2.0.0.0-9eb8dabb420ff8895b120c46656b2297 -package-id pretty-1.1.0.0-a71ea30eded99ca18503f9083b61c91a -package-id syb-0.3.3-a30fb29604a386579941b5a6f9820dc4 -O -XHaskell98 -XCPP Language.Haskell.Lexer Language.Haskell.Parser Language.Haskell.ParseMonad Language.Haskell.Pretty Language.Haskell.Syntax Language.Haskell.ParseUtils

Implicit import declaration:
    Ambiguous module name `Prelude':
      it was found in multiple packages: base haskell98-2.0.0.0

comment:4 Changed 4 years ago by AndreasVoellmy

I was able to install haskell-src after removing the dependency on haskell98 listed in its cabal file.
hint also needs ghc-mtl, and now this is my stumbling block. It uses the ghc package but fails to find the definitions.
Here is a transcript of my cabal commands:

$ cabal configure -v
/usr/bin/ghc --numeric-version
looking for tool "ghc-pkg" near compiler in /usr/bin
found ghc-pkg in /usr/bin/ghc-pkg
/usr/bin/ghc-pkg --version
/usr/bin/ghc --supported-languages
/usr/bin/ghc --info
Reading available packages...
Resolving dependencies...
Configuring ghc-mtl-1.0.1.0...
Dependency MonadCatchIO-mtl ==0.3.0.3: using MonadCatchIO-mtl-0.3.0.3
Dependency base ==4.4.0.0: using base-4.4.0.0
Dependency ghc ==7.2.1: using ghc-7.2.1
Dependency mtl ==2.0.1.0: using mtl-2.0.1.0
Using Cabal-1.10.2.0 compiled by ghc-7.0
Using compiler: ghc-7.2.1
Using install prefix: /Users/Andreas/.cabal
Binaries installed in: /Users/Andreas/.cabal/bin
Libraries installed in: /Users/Andreas/.cabal/lib/ghc-mtl-1.0.1.0/ghc-7.2.1
Private binaries installed in: /Users/Andreas/.cabal/libexec
Data files installed in: /Users/Andreas/.cabal/share/ghc-mtl-1.0.1.0
Documentation installed in: /Users/Andreas/.cabal/share/doc/ghc-mtl-1.0.1.0
Using alex version 2.3.5 found on system at: /usr/bin/alex
Using ar found on system at: /usr/bin/ar
Using c2hs version 0.16.3 found on system at:
/Users/Andreas/Library/Haskell/bin/c2hs
Using cpphs version 1.12 found on system at: /Users/Andreas/.cabal/bin/cpphs
No ffihugs found
Using gcc version 4.2.1 found on system at: /usr/bin/gcc
Using ghc version 7.2.1 found on system at: /usr/bin/ghc
Using ghc-pkg version 7.2.1 found on system at: /usr/bin/ghc-pkg
No greencard found
Using haddock version 2.9.2 found on system at: /usr/bin/haddock
Using happy version 1.18.6 found on system at: /usr/bin/happy
No hmake found
Using hsc2hs version 0.67 found on system at: /usr/bin/hsc2hs
No hscolour found
No hugs found
No jhc found
Using ld found on system at: /usr/bin/ld
No lhc found
No lhc-pkg found
No nhc98 found
No pkg-config found
Using ranlib found on system at: /usr/bin/ranlib
Using strip found on system at: /usr/bin/strip
Using tar found on system at: /usr/bin/tar
No uhc found
$ cabal build -v
creating dist/build
creating dist/build/autogen
Preprocessing library ghc-mtl-1.0.1.0...
Building ghc-mtl-1.0.1.0...
Building library...
creating dist/build
/usr/bin/ghc --make -package-name ghc-mtl-1.0.1.0 -hide-all-packages -fbuilding-cabal-package -i -idist/build -i. -idist/build/autogen -Idist/build/autogen -Idist/build -optP-include -optPdist/build/autogen/cabal_macros.h -odir dist/build -hidir dist/build -stubdir dist/build -package-id MonadCatchIO-mtl-0.3.0.3-3cd1bc0713792fc98d4bc4917fa08d03 -package-id base-4.4.0.0-b81f1ae0118e4c9367b9db3fd76eea62 -package-id ghc-7.2.1-9cecf4edd60040c5413135a0ef392236 -package-id mtl-2.0.1.0-22e17c8b374ae14036993ac70bb99b1a -O -Wall -O2 -XHaskell98 -XGeneralizedNewtypeDeriving Control.Monad.Ghc
[1 of 1] Compiling Control.Monad.Ghc ( Control/Monad/Ghc.hs, dist/build/Control/Monad/Ghc.o )

Control/Monad/Ghc.hs:19:22:
    Not in scope: type constructor or class `GHC.Ghc'

Control/Monad/Ghc.hs:21:15:
    Not in scope: type constructor or class `GHC.WarnLogMonad'

Control/Monad/Ghc.hs:21:66:
    Not in scope: type constructor or class `GHC.GhcMonad'

Control/Monad/Ghc.hs:34:37:
    Not in scope: type constructor or class `GHC.GhcT'

Control/Monad/Ghc.hs:41:19: Not in scope: `GHC.liftGhcT'

Control/Monad/Ghc.hs:59:27:
    Not in scope: type constructor or class `GHC.WarnLogMonad'

Control/Monad/Ghc.hs:60:5:
    `setWarnings' is not a (visible) method of class `WarnLogMonad'

Control/Monad/Ghc.hs:60:26: Not in scope: `GHC.setWarnings'

Control/Monad/Ghc.hs:61:5:
    `getWarnings' is not a (visible) method of class `WarnLogMonad'

Control/Monad/Ghc.hs:61:24: Not in scope: `GHC.getWarnings'

Control/Monad/Ghc.hs:63:41:
    Not in scope: type constructor or class `GHC.GhcMonad'

Control/Monad/Ghc.hs:64:5:
    `getSession' is not a (visible) method of class `GhcMonad'

Control/Monad/Ghc.hs:64:23: Not in scope: `GHC.getSession'

Control/Monad/Ghc.hs:65:5:
    `setSession' is not a (visible) method of class `GhcMonad'

Control/Monad/Ghc.hs:65:25: Not in scope: `GHC.setSession'

When I run ghc-pkg list I see that ghc-7.2.1 is listed in blue.

comment:5 Changed 4 years ago by chak

Hmm, it seems that the package maintainers didn't bother to adapt their packages when the 7.2.1 release candidates were out.

comment:6 Changed 4 years ago by igloo

  • Milestone set to 7.4.1
  • Status changed from new to infoneeded

Could you see if you can make a self-contained testcase, please? That would make it a lot easier for us to try to reproduce and fix the problem.

comment:7 Changed 3 years ago by igloo

  • difficulty set to Unknown
  • Milestone changed from 7.4.1 to 7.6.1

comment:8 Changed 3 years ago by George

Unable to reproduce bug on Mac OS 10.8.1 (Mountain Lion) with latest 32 bit Haskell platform. I first did cabal install syntax-trees and was then able to compile and load the file (original bug) and evaluate ex1 which gave the expected value of "42"

comment:9 Changed 3 years ago by simonmar

  • Resolution set to worksforme
  • Status changed from infoneeded to closed

Thanks - this bug has been open for 13 months with no further info and there's evidence that it isn't reproducible (any more), so I'm closing it.

Note: See TracTickets for help on using tickets.