Opened 11 years ago

Closed 11 years ago

Last modified 4 years ago

#906 closed bug (fixed)

"the `impossible' happened: Maybe.fromJust: Nothing" when using {-# SOURCE #-}

Reported by: Misha Aizatulin <avatar@…> Owned by: simonmar
Priority: normal Milestone: 6.6
Component: Compiler Version: 6.4.2
Keywords: Cc: avatar@…
Operating System: Linux Architecture: x86
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


It is possible to use the {-# SOURCE #-} directive to make ghc crash. Attached is a program that does it with ghc 6.4.2. Here is a run of my compiler:

avatar@avatar:~/Docs/sandbox/haskell/hs-boot> make
ghc --make Main.hs
Chasing modules from: Main.hs
Compiling C                ( ./C.hs, ./C.o )
Compiling A                ( ./A.hs, ./A.o )
Compiling A[boot]          ( ./A.hs-boot, ./A.o-boot )
Compiling B                ( ./B.hs, ./B.o )
Compiling Main             ( Main.hs, Main.o )
Linking ...
ghc-6.4.2: panic! (the `impossible' happened, GHC version 6.4.2):
        Maybe.fromJust: Nothing

The bang seems to happen in

./compiler/main/DriverPipeline.hs:320:      linkables = map (fromJust.hm_linkable) home_mod_infos

though I'm not 100% sure.



Attachments (1)

hs-boot.tar.gz (520 bytes) - added by Misha Aizatulin <avatar@…> 11 years ago.

Download all attachments as: .zip

Change History (6)

Changed 11 years ago by Misha Aizatulin <avatar@…>

Attachment: hs-boot.tar.gz added

comment:1 Changed 11 years ago by simonpj

We know what is going on here; module A is being compiled before A.hs-boot, so when the latter is compiled it overwrites the in-memory record of the object code of A.

Solution: add edge from A.hs-boot to A.hs. This is a Good Thing anyway, because A.hs-boot should not depend on A.hs (i.e. adding the edge prevents another odd case). But adding the edge also means that A.hs-boot will never overwrite A.hs in the HPT.

Guaranteeing such a message is a bit more work. See Task #914

comment:2 Changed 11 years ago by simonpj

Milestone: 6.6
Owner: set to simonpj

comment:3 Changed 11 years ago by simonpj

Owner: changed from simonpj to simonmar

comment:4 Changed 11 years ago by simonmar

Resolution: fixed
Status: newclosed

Done, test is programs/hs-boot.

Thu Sep 28 16:17:05 BST 2006  Simon Marlow <>
  * Fix #906, and do #914 while I'm in here (it wasn't too hard)

comment:5 Changed 4 years ago by Simon Marlow <simonmar@…>

Note: See TracTickets for help on using tickets.