#1186: GHC as a library panic on loading second module
------------------------------+---------------------------------------------
 Reporter:  ArthurVanLeeuwen  |          Owner:         
     Type:  bug               |         Status:  new    
 Priority:  normal            |      Milestone:         
Component:  GHC API           |        Version:  6.6    
 Severity:  normal            |     Resolution:         
 Keywords:                    |     Difficulty:  Unknown
 Testcase:                    |   Architecture:  powerpc
       Os:  Unknown           |  
------------------------------+---------------------------------------------
Comment (by ArthurVanLeeuwen):

 Just to check my sanity (the bugreport was an attempted pare-down of the
 original problem):

 {{{
 harlan:~/Werk/dss/software/ghclib arthurvl$ uname -a
 Darwin harlan.cs.uu.nl 8.8.0 Darwin Kernel Version 8.8.0: Fri Sep  8
 17:18:57 PDT 2006; root:xnu-792.12.6.obj~1/RELEASE_PPC Power Macintosh
 powerpc
 harlan:~/Werk/dss/software/ghclib arthurvl$ echo "setupsession >>=
 loadsession" | ghci -package ghc ghclibtest.hs
    ___         ___ _
   / _ \ /\  /\/ __(_)
  / /_\// /_/ / /  | |      GHC Interactive, version 6.6, for Haskell 98.
 / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
 \____/\/ /_/\____/|_|      Type :? for help.

 Loading package base ... linking ... done.
 Loading package template-haskell ... linking ... done.
 Loading package readline-1.0 ... linking ... done.
 Loading package unix-1.0 ... linking ... done.
 Loading package Cabal-1.1.6 ... linking ... done.
 Loading package regex-base-0.71 ... linking ... done.
 Loading package regex-posix-0.71 ... linking ... done.
 Loading package regex-compat-0.71 ... linking ... done.
 Loading package haskell98 ... linking ... done.
 Loading package ghc-6.6 ... linking ... done.
 [1 of 2] Compiling OtherModule      ( OtherModule.hs, interpreted )
 [2 of 2] Compiling GHCLibTest       ( ghclibtest.hs, interpreted )
 Ok, modules loaded: OtherModule, GHCLibTest.
 *GHCLibTest> ghc-6.6: panic! (the 'impossible' happened)
   (GHC version 6.6 for powerpc-apple-darwin):
         lookup_dfun main:OtherModule.$f1{v r5x8} [lid]

 Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

 *GHCLibTest> Leaving GHCi.
 harlan:~/Werk/dss/software/ghclib arthurvl$ lsOtherModule.hs
 ghclibtest.hs
 harlan:~/Werk/dss/software/ghclib arthurvl$ cat OtherModule.hs
 module OtherModule where

 import Data.List

 type Nummer = String

 data Beademing = HFO | CPAP | IPPV | Geen
     deriving (Show, Read, Eq)
 data Bloeddruk = Hypertensie | Hypotensie | TensieNormaal
     deriving (Show, Read, Eq)
 data Partus = PartusTeVroeg | PartusNormaal
     deriving (Show, Read, Eq)
 harlan:~/Werk/dss/software/ghclib arthurvl$ cat ghclibtest.hs
 module GHCLibTest (setupsession,loadsession) where

 import GHC
 import PackageConfig
 import DynFlags
 import OtherModule

 main = setupsession >>= loadsession

 setupsession =
     do session <- newSession JustTypecheck (Just "/usr/local/lib/ghc-6.6")
        f <- getSessionDynFlags session
        f' <- parseDynamicFlags f ["-package ghc"]
        setSessionDynFlags session (fst f'){hscTarget = HscInterpreted}
        let preludeModule = mkModule (stringToPackageId "base")
 (mkModuleName "Prelude")
        setContext session [] [preludeModule]
        t <- guessTarget "ghclibtest.hs" Nothing
        addTarget session t
        return session

 loadsession session = load session LoadAllTargets

 other = 12
 }}}

 I did note however, that *compiling* this does not seem to evoke the bug:

 {{{
 harlan:~/Werk/dss/software/ghclib arthurvl$ ghc -package ghc --make -main-
 is GHCLibTest.main ghclibtest.hs
 [1 of 2] Compiling OtherModule      ( OtherModule.hs, OtherModule.o )
 [2 of 2] Compiling GHCLibTest       ( ghclibtest.hs, ghclibtest.o )
 Linking ghclibtest ...
 harlan:~/Werk/dss/software/ghclib arthurvl$ ./ghclibtest
 harlan:~/Werk/dss/software/ghclib arthurvl$ ls
 OtherModule.hi  OtherModule.o   ghclibtest.hi   ghclibtest.o
 OtherModule.hs  ghclibtest      ghclibtest.hs
 }}}

 And then using the compiled modules with ghci doesn't break things anymore
 either!

 {{{
 harlan:~/Werk/dss/software/ghclib arthurvl$ echo "setupsession >>=
 loadsession" | ghci -package ghc ghclibtest.hs
    ___         ___ _
   / _ \ /\  /\/ __(_)
  / /_\// /_/ / /  | |      GHC Interactive, version 6.6, for Haskell 98.
 / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
 \____/\/ /_/\____/|_|      Type :? for help.

 Loading package base ... linking ... done.
 Loading package template-haskell ... linking ... done.
 Loading package readline-1.0 ... linking ... done.
 Loading package unix-1.0 ... linking ... done.
 Loading package Cabal-1.1.6 ... linking ... done.
 Loading package regex-base-0.71 ... linking ... done.
 Loading package regex-posix-0.71 ... linking ... done.
 Loading package regex-compat-0.71 ... linking ... done.
 Loading package haskell98 ... linking ... done.
 Loading package ghc-6.6 ... linking ... done.
 Ok, modules loaded: OtherModule, GHCLibTest.
 Prelude GHCLibTest> Prelude GHCLibTest> Leaving GHCi.
 harlan:~/Werk/dss/software/ghclib arthurvl$
 }}}

 Maybe the intermediate code for interpreted modules isn't re-entrant
 enough? :)

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1186>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to